mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-16 08:08:18 +00:00
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { Platform } from "react-native";
|
|
|
|
const BackgroundFetch = !Platform.isTV
|
|
? require("expo-background-fetch")
|
|
: null;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
export const BACKGROUND_FETCH_TASK_SESSIONS = "background-fetch-sessions";
|
|
|
|
export async function registerBackgroundFetchAsyncSessions() {
|
|
try {
|
|
console.log("Registering background fetch sessions");
|
|
BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK_SESSIONS, {
|
|
minimumInterval: 1 * 60, // 1 minutes
|
|
stopOnTerminate: false, // android only,
|
|
startOnBoot: true, // android only
|
|
});
|
|
} catch (error) {
|
|
console.log("Error registering background fetch task", error);
|
|
}
|
|
}
|
|
|
|
export async function unregisterBackgroundFetchAsyncSessions() {
|
|
try {
|
|
BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK_SESSIONS);
|
|
} catch (error) {
|
|
console.log("Error unregistering background fetch task", error);
|
|
}
|
|
}
|