UNPKG

2.42 kBTypeScriptView Raw
1import { BackgroundFetchOptions, BackgroundFetchResult, BackgroundFetchStatus } from './BackgroundFetch.types';
2/**
3 * Gets a status of background fetch.
4 * @return Returns a promise which fulfils with one of `BackgroundFetchStatus` enum values.
5 */
6export declare function getStatusAsync(): Promise<BackgroundFetchStatus | null>;
7/**
8 * Sets the minimum number of seconds that must elapse before another background fetch can be
9 * initiated. This value is advisory only and does not indicate the exact amount of time expected
10 * between fetch operations.
11 *
12 * > This method doesn't take any effect on Android. It is a global value which means that it can
13 * overwrite settings from another application opened through Expo Go.
14 *
15 * @param minimumInterval Number of seconds that must elapse before another background fetch can be called.
16 * @return A promise which fulfils once the minimum interval is set.
17 */
18export declare function setMinimumIntervalAsync(minimumInterval: number): Promise<void>;
19/**
20 * Registers background fetch task with given name. Registered tasks are saved in persistent storage and restored once the app is initialized.
21 * @param taskName Name of the task to register. The task needs to be defined first - see [`TaskManager.defineTask`](taskmanager#defineTask)
22 * for more details.
23 * @param options An object containing the background fetch options.
24 *
25 * @example
26 * ```ts
27 * import * as BackgroundFetch from 'expo-background-fetch';
28 * import * as TaskManager from 'expo-task-manager';
29 *
30 * TaskManager.defineTask(YOUR_TASK_NAME, () => {
31 * try {
32 * const receivedNewData = // do your background fetch here
33 * return receivedNewData ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;
34 * } catch (error) {
35 * return BackgroundFetch.BackgroundFetchResult.Failed;
36 * }
37 * });
38 * ```
39 */
40export declare function registerTaskAsync(taskName: string, options?: BackgroundFetchOptions): Promise<void>;
41/**
42 * Unregisters background fetch task, so the application will no longer be executing this task.
43 * @param taskName Name of the task to unregister.
44 * @return A promise which fulfils when the task is fully unregistered.
45 */
46export declare function unregisterTaskAsync(taskName: string): Promise<void>;
47export { BackgroundFetchResult, BackgroundFetchStatus, BackgroundFetchOptions };
48//# sourceMappingURL=BackgroundFetch.d.ts.map
\No newline at end of file