BackgroundFetch not running

So far I have not been able to see that BackgroundFetch runs. As part of the task I am logging to my server when the task is registered and when the task is run. I can see that the task gets registered but I never see any logs to show the task has run.

app.json

"ios": {
    "infoPlist": {
        "UIBackgroundModes": [
		"location",
		"fetch"
	]

definition of task called from App.json

defineHealthTask = () => {
		TaskManager.defineTask(taskName, async () => {
			try {
				await UserRemoteLogService.logWithTaskType("STEPS_TASK_RUNNING");
				return BackgroundFetch.Result.NewData;
			} catch (error) {
			        return BackgroundFetch.Result.Failed;
			}
		});
	};

registering task

        await UserRemoteLogService.logWithTaskType("STEPS_TASK_REGISTRATION_REQUESTED");
	const pedometerAvailable = await Pedometer.isAvailableAsync();
	const backGroundFetchStatus = await BackgroundFetch.getStatusAsync();
	if (pedometerAvailable && BackgroundFetch.Status.Available === backGroundFetchStatus) {
		await BackgroundFetch.registerTaskAsync(taskName, {
			userBusinessId: user.businessId
		});
		UserRemoteLogService.logWithTaskType("STEPS_TASK_REGISTERED");
	}

in my backend I see that the task is registered but I never see a log to show that it has run, the logging service works in a defined task for location so i see no reason why I should not be seeing the log it this task was running.

So the question is have people seen this background task running? Have i missed something obvious which i should have set?

2 Likes

Just to say, Iā€™m having this issue also, exactly as you describe.
Also this stackoverflow post indicates the same problem: react native - expo.io's BackgroundFetch is not running the defined task - Stack Overflow

Is it because BackgroundFetch does not work when using the app through the Expo client? and only works with a standalone app?

For me i am not seeing it work at all on a standalone app

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.