As I've understood from the documentation, you initiate a default task (which runs when your app is minimized) and also optionally a headless task (which runs when your app is terminated). Like this:
//configure normal background task, set time interval as 15 minutes.
BackgroundFetch.configure({
minimumFetchInterval: 15
}, async (taskId) => {
console.log("[BackgroundFetch] taskId: ", taskId);
// Finish, providing received taskId.
BackgroundFetch.finish(taskId);
}, async (taskId) => {
BackgroundFetch.finish(taskId);
});
let MyHeadlessTask = async (event) => {
let taskId = event.taskId;
let isTimeout = event.timeout;
if (isTimeout) {
BackgroundFetch.finish(taskId);
return;
}
console.log('[BackgroundFetch HeadlessTask] start: ', taskId);
// some task..
BackgroundFetch.finish(taskId);
}
// Register your BackgroundFetch HeadlessTask, which also runs every 15 minutes, because of the above configuration of minimumFetchInterval.
BackgroundFetch.registerHeadlessTask(MyHeadlessTask);
What I want is to be able to register only a headless task, with the minimumFetchInterval configuration. Something like this:
BackgroundFetch.registerHeadlessTask(MyHeadlessTask, {
minimumFetchInterval: 15
});
But I know registerHeadlessTask does not take configuration input. Is there any other way to do it?
Now in your new task try doing work directly or maybe try creating headless task again there in which you do your work