-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Description
Environment
Expo CLI 2.11.1 environment info:
System:
OS: macOS 10.14.3
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.6.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.8.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmGlobalPackages:
expo-cli: 2.11.1
app's target - iOS, Standalone
Steps to Reproduce
- Allow background fetch in app.json
"ios": {
"infoPlist": {
"UIBackgroundModes": [
"location",
"fetch"
]
- define a task in App.js
defineHealthTask = () => {
TaskManager.defineTask(taskName, async () => {
try {
await UserRemoteLogService.logWithTaskType("STEPS_TASK_RUNNING");
return BackgroundFetch.Result.NewData;
} catch (error) {
return BackgroundFetch.Result.Failed;
}
});
};
- register task at some point of the apps running
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");
}
- set minimum interval for task in seconds
BackgroundFetch.setMinimumIntervalAsync(60);
Expected Behavior
App should periodically call my server to log that the background task is running
Actual Behavior
Never see the background task run, although i do see the logs that show the background task was registered. The logging service i use has been used to show when location background task has run so this logging service should log if the task runs
My main question is has anyone seen background fetch run? if so have i just configured it wrong?