Closed koreahn closed 2 weeks ago
varies inconsistently.
Yes, that's to be expected. The OS is interested in preserving device battery. It decides when it's ready to fire an event.
varies inconsistently.
Yes, that's to be expected. The OS is interested in preserving device battery. It decides when it's ready to fire an event.
Thank you for your reply. Can you tell me why it doesn't work on iOS? I have set up all the configurations according to the setup guides.
See readme to learn how to simulate events in iOS. If simulated events work, that's all you need to do to know that it works. After that, you must wait several days before regular events beginning.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Your Environment
react-native -v
): 0.73.4Expected Behavior
Actual Behavior
I have set up all the configurations according to the setup guides.(Android / iOS both)
The 'minimumFetchInterval' is not working as expected. Regardless of whether it is set to 1 or 30, the automatic execution interval varies inconsistently.
The app automatically runs when it is closed (not in the background), although the execution interval is not as per the configured settings. However, an error occurs stating that the executing function is not defined.
It's not working on iOS.
Steps to Reproduce
1. 2. 4. 5.
Context
Belows are my code.
let MyHeadlessTask = async event => { // Get task id from event {}: let taskId = event.taskId; let isTimeout = event.timeout; // <-- true when your background-time has expired. if (isTimeout) { // This task has exceeded its allowed running-time. // You must stop what you're doing immediately finish(taskId) console.log('[BackgroundFetch] Headless TIMEOUT:', taskId); BackgroundFetch.finish(taskId); return; } console.log('[BackgroundFetch HeadlessTask] start: ', taskId);
// Perform an example HTTP request. // Important: await asychronous tasks when using HeadlessJS. const {saveLocation} = require('./App'); const location = await saveLocation('auto'); console.log('[BackgroundFetch HeadlessTask] location: ', location);
// Required: Signal to native code that your task is complete. // If you don't do this, your app could be terminated and/or assigned // battery-blame for consuming too much time in background. BackgroundFetch.finish(taskId); };
// Register your BackgroundFetch HeadlessTask BackgroundFetch.registerHeadlessTask(MyHeadlessTask);
useEffect(() => { if (!dbUser) return; initBackgroundFetch(); }, [dbUser]);
const initBackgroundFetch = async () => { try { const onEvent = async taskId => { console.log('BackgroundFetch event triggered. Task ID:', taskId); console.log(new Date());
};