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OAAO,CAAC,CAAC;AACjE,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,CAAC;QAC7C,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAA0B,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as TaskManager from 'expo-task-manager';\n\nimport {\n BackgroundFetchOptions,\n BackgroundFetchResult,\n BackgroundFetchStatus,\n} from './BackgroundFetch.types';\nimport ExpoBackgroundFetch from './ExpoBackgroundFetch';\n\n// @needsAudit\n/**\n * Gets a status of background fetch.\n * @return Returns a promise which fulfils with one of `BackgroundFetchStatus` enum values.\n */\nexport async function getStatusAsync(): Promise<BackgroundFetchStatus | null> {\n if (Platform.OS === 'android') {\n return BackgroundFetchStatus.Available;\n }\n return ExpoBackgroundFetch.getStatusAsync();\n}\n\n// @needsAudit\n/**\n * Sets the minimum number of seconds that must elapse before another background fetch can be\n * initiated. This value is advisory only and does not indicate the exact amount of time expected\n * between fetch operations.\n *\n * > This method doesn't take any effect on Android. It is a global value which means that it can\n * overwrite settings from another application opened through Expo Go.\n *\n * @param minimumInterval Number of seconds that must elapse before another background fetch can be called.\n * @return A promise which fulfils once the minimum interval is set.\n */\nexport async function setMinimumIntervalAsync(minimumInterval: number): Promise<void> {\n if (!ExpoBackgroundFetch.setMinimumIntervalAsync) {\n return;\n }\n // iOS only\n await ExpoBackgroundFetch.setMinimumIntervalAsync(minimumInterval);\n}\n\n// @needsAudit\n/**\n * Registers background fetch task with given name. Registered tasks are saved in persistent storage and restored once the app is initialized.\n * @param taskName Name of the task to register. The task needs to be defined first - see [`TaskManager.defineTask`](taskmanager#defineTask)\n * for more details.\n * @param options An object containing the background fetch options.\n *\n * @example\n * ```ts\n * import * as BackgroundFetch from 'expo-background-fetch';\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, () => {\n * try {\n * const receivedNewData = // do your background fetch here\n * return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;\n * } catch (error) {\n * return BackgroundFetch.BackgroundFetchResult.Failed;\n * }\n * });\n * ```\n */\nexport async function registerTaskAsync(\n taskName: string,\n options: BackgroundFetchOptions = {}\n): Promise<void> {\n if (!ExpoBackgroundFetch.registerTaskAsync) {\n throw new UnavailabilityError('BackgroundFetch', 'registerTaskAsync');\n }\n if (!TaskManager.isTaskDefined(taskName)) {\n throw new Error(\n `Task '${taskName}' is not defined. You must define a task using TaskManager.defineTask before registering.`\n );\n }\n await ExpoBackgroundFetch.registerTaskAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Unregisters background fetch task, so the application will no longer be executing this task.\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfils when the task is fully unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoBackgroundFetch.unregisterTaskAsync) {\n throw new UnavailabilityError('BackgroundFetch', 'unregisterTaskAsync');\n }\n await ExpoBackgroundFetch.unregisterTaskAsync(taskName);\n}\n\nexport { BackgroundFetchResult, BackgroundFetchStatus, BackgroundFetchOptions };\n"]}
\No newline at end of file