I am having issues getting the background fetch to run (at all) on iOS on a non-ejected SDK 33 project through the client app. It is working just fine on Android. I believe I have followed the steps in the docs correctly but have been unable to get it to run on iOS. I have included a snippet of my code below, if anyone could point out my issue it would be greatly appreciated.
const startBackgroundTask = async () => { // called from the global scope in app.js
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
Logger.debug(FILE, 'BackgroundTask running');
try {
// Do the fetch...
return BackgroundFetch.Result.NewData;
} catch (err) {
Logger.error(FILE, `Error occured while running task: ${err.message}`, err);
return BackgroundFetch.Result.Failed;
}
});
const status = await BackgroundFetch.getStatusAsync();
if (status === BackgroundFetch.Status.Restricted || status === BackgroundFetch.Status.Denied) {
Logger.warn(FILE, 'Background fetch is disabled.');
return;
}
try {
await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: INTERVAL,
stopOnTerminate: true,
startOnBoot: false,
});
await BackgroundFetch.setMinimumIntervalAsync(INTERVAL);
Logger.debug(FILE, 'Background update task registered.');
} catch (err) {
Logger.error(FILE, 'Filed to register task for background.', err);
}
}