BackgroundFetch - Android - Cannot read property 'registerTaskAsync' of undefined

Please provide the following:

  1. SDK Version: 49
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I get this error

  • Cannot read property ‘registerTaskAsync’ of undefined
    when I try to register a background task on Android. On IOS it worked fine.

TaskManager.isTaskRegisteredAsync doesn’t work either

_layout.tsx
TaskManager.defineTask(BACKGROUND_FETCH_TASK_CALENDAR, () => {
try {

return BackgroundFetch.BackgroundFetchResult.NewData;
} catch (error) {
return BackgroundFetch.BackgroundFetchResult.Failed;
}
});

home.tsx

const checkStatusAsync = async () => {
const status = await BackgroundFetch.getStatusAsync();
const isRegistered = await TaskManager.isTaskRegisteredAsync(
BACKGROUND_FETCH_TASK_CALENDAR
);
if (status) setStatus(status);
setIsRegistered(isRegistered);
};

useEffect(() => {
async function registerBackgroundFetchAsync() {
return await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK_CALENDAR, {
minimumInterval: 60 * 15,
stopOnTerminate: false, // android only,
startOnBoot: true, // android only
});
}
registerBackgroundFetchAsync();
checkStatusAsync();
}, );

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