transistorsoft/react-native-background-fetch

The plugin not working in iOS real device after setting up 15 mins interval.

railsfactory-ashish opened this issue · 6 comments

Your Environment

  • Plugin version: 4.2.1
  • Platform: iOS
  • OS version: 16.6
  • Device manufacturer / model: iPhone 12 mini
  • React Native version (react-native -v): 0.72.4
  • Plugin config

Expected Behaviour

The plugin should trigger notification after every 15 mins when app is killed.

Actual Behaviour

Not getting triggered even single time.

Steps to Reproduce

  1. Install plugin
  2. Enable background fetch and background processing in xCode.
  3. write below code in separate file and import it in app.js file

const initBackgroundFetch = async () => {
const status = await BackgroundFetch.configure(
{
minimumFetchInterval: 15,
stopOnTerminate: false,
enableHeadless: true,
startOnBoot: true,
},
handleTask,
onTimeout
);
BackgroundFetch.start().then((value) => console.log(value, 'ok'));
};

// handleTask is called periodically when RNBF triggers an event
const handleTask = async (taskId) => {
console.log('nops');
triggerNotification();
BackgroundFetch.finish(taskId);
};

const triggerNotification = () => {
const time = DateTime.now().plus({ seconds: 60 });
const jsDate = DateTime.now().set({
hour: time.get('hour'),
minute: time.get('minute'),
});
console.log(jsDate.toMillis(), 'jsDate.toMillis()');
const trigger = {
type: TriggerType.TIMESTAMP,
timestamp: jsDate.toMillis(),
alarmManager: {
allowWhileIdle: true,
},
};
notifee.createTriggerNotification(
{
id: v4(),
title: 'test',
body: 'opps',
data: {
type: 'task',
id: 'nope',
},
ios: {
sound: 'default',
categoryId: 'done',
},
},
trigger
);
};
const onTimeout = async () => {
// The timeout function is called when the OS signals that the task has reached its maximum execution time.

// ADD CLEANUP WORK HERE (IF NEEDED)

BackgroundFetch.finish(taskId);
};
initBackgroundFetch() // calling the function here

Context

I was trying to trigger notification every 15 mins

Debug logs

2023-09-16 12:14:00.916686+0530 myiOSApp[29397:1314042] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 95 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 95 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2023-09-16 12:14:00.938540+0530 myiOSApp[29397:1314037] 10.14.0 - [I-ACS025027] Deferring to Google Analytics for Firebase for event data collection. https://goo.gl/YNbdK2
2023-09-16 12:14:00.961875+0530 myiOSApp[29397:1314047] [javascript] Running "myiOSApp
2023-09-16 12:14:00.992622+0530 myiOSApp[29397:1314047] [javascript] 1694846700992, 'jsDate.toMillis()'
2023-09-16 12:14:01.038791+0530 myiOSApp[29397:1313806] [TSBackgroundFetch scheduleBGAppRefresh] com.transistorsoft.fetch
2023-09-16 12:14:01.078182+0530 myiOSApp[29397:1314047] [javascript] iosStoreURL is not set.
2023-09-16 12:14:01.118963+0530 myiOSApp[29397:1313806] To get test ads on this device, set:
Objective-C
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = @[ @"1ae1bc50e874a825f4fdd7e4120a5c60" ];
Swift
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [ "1ae1bc50e874a825f4fdd7e4120a5c60" ]
2023-09-16 12:14:01.249680+0530 myiOSApp[29397:1313806] [TSBackgroundFetch start] (null)
2023-09-16 12:14:01.250944+0530 myiOSApp[29397:1314047] [javascript] 2, 'ok'
2023-09-16 12:14:01.373245+0530 myiOSApp[29397:1314046] [quic] quic_crypto_session_state_serialize [C1.1.1.1:2] [-ef6b0ba9525f4045] TLS ticket does not fit (6927 > 6144)
2023-09-16 12:14:01.373386+0530 myiOSApp[29397:1314046] [quic] quic_crypto_session_state_serialize [C1.1.1.1:2] [-ef6b0ba9525f4045] TLS ticket does not fit (6927 > 6144)
2023-09-16 12:14:29.731285+0530 myiOSApp[29397:1314045] [connection] nw_connection_add_timestamp_locked_on_nw_queue [C1] Hit maximum timestamp count, will start dropping events
2023-09-16 12:14:29.734747+0530 myiOSApp[29397:1314045] [connection] nw_connection_add_timestamp_locked_on_nw_queue [C3] Hit maximum timestamp count, will start dropping events
2023-09-16 12:15:14.993123+0530 myiOSApp[29397:1313806] [TSBackgroundFetch onAppTerminate]

@christocracy I have downloaded the repo and installed the FetchDemo app in my iPhone through Xcode and I could see UI that the app can show all the events that will be triggered in killed state and should be displayed whenever I will open the app letter. but so far no events I could see.
Please let me know if I am missing any steps?