This commit is contained in:
Fredrik Burmester
2024-10-01 17:42:09 +02:00
parent dd1f02a13b
commit 0acc1f03f0
12 changed files with 425 additions and 130 deletions

23
utils/background-tasks.ts Normal file
View File

@@ -0,0 +1,23 @@
import * as BackgroundFetch from "expo-background-fetch";
export const BACKGROUND_FETCH_TASK = "background-fetch";
export async function registerBackgroundFetchAsync() {
try {
BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: 60 * 1, // 1 minutes
stopOnTerminate: false, // android only,
startOnBoot: false, // android only
});
} catch (error) {
console.log("Error registering background fetch task", error);
}
}
export async function unregisterBackgroundFetchAsync() {
try {
BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);
} catch (error) {
console.log("Error unregistering background fetch task", error);
}
}