You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sorry if I didn't follow the 'issue format' I just couln't fit it in.
But the registered tasks don't execute.
This is the code given in the examples and I tried to paste it in my code and nothing really happened.
I am using Expo for this and I have followed all the steps to set up on Expo.
The only problem is that I can't run the function in the background as it was supposed to
letMyHeadlessTask=async(event)=>{// Get task id from event {}:console.log("registering")lettaskId=event.taskId;letisTimeout=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.letresponse=awaitfetch('https://reactnative.dev/movies.json');letresponseJson=awaitresponse.json();console.log('[BackgroundFetch HeadlessTask] response: ',responseJson);// 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 HeadlessTaskBackgroundFetch.registerHeadlessTask(MyHeadlessTask);
Sorry I am a bit new to all this!
The text was updated successfully, but these errors were encountered:
I’m not sure you understand what the Android HeadlessTask is. That only runs in the specific case where the Android app is terminated; not merely when your app is in the background.
I am sorry if I didn't follow the 'issue format' I just couln't fit it in.
But the registered tasks don't execute.
This is the code given in the examples and I tried to paste it in my code and nothing really happened.
I am using Expo for this and I have followed all the steps to set up on Expo.
The only problem is that I can't run the function in the background as it was supposed to
Sorry I am a bit new to all this!
The text was updated successfully, but these errors were encountered: