1/** 2 * Error object that can be received through [`TaskManagerTaskBody`](#taskmanagertaskbody) when the 3 * task fails. 4 */ 5export interface TaskManagerError { 6 code: string | number; 7 message: string; 8} 9/** 10 * Represents the object that is passed to the task executor. 11 */ 12export interface TaskManagerTaskBody<T = object> { 13 /** 14 * An object of data passed to the task executor. Its properties depends on the type of the task. 15 */ 16 data: T; 17 /** 18 * Error object if the task failed or `null` otherwise. 19 */ 20 error: TaskManagerError | null; 21 /** 22 * Additional details containing unique ID of task event and name of the task. 23 */ 24 executionInfo: TaskManagerTaskBodyExecutionInfo; 25} 26/** 27 * Additional details about execution provided in `TaskManagerTaskBody`. 28 */ 29export interface TaskManagerTaskBodyExecutionInfo { 30 /** 31 * __(iOS only)__ State of the application. 32 */ 33 appState?: 'active' | 'background' | 'inactive'; 34 /** 35 * Unique ID of task event. 36 */ 37 eventId: string; 38 /** 39 * Name of the task. 40 */ 41 taskName: string; 42} 43/** 44 * Represents an already registered task. 45 */ 46export interface TaskManagerTask { 47 /** 48 * Name that the task is registered with. 49 */ 50 taskName: string; 51 /** 52 * Type of the task which depends on how the task was registered. 53 */ 54 taskType: string; 55 /** 56 * Provides `options` that the task was registered with. 57 */ 58 options: any; 59} 60/** 61 * @deprecated Use `TaskManagerTask` instead. 62 * @hidden 63 */ 64export interface RegisteredTask extends TaskManagerTask { 65} 66/** 67 * Type of task executor – a function that handles the task. 68 */ 69export declare type TaskManagerTaskExecutor = (body: TaskManagerTaskBody) => void; 70/** 71 * Defines task function. It must be called in the global scope of your JavaScript bundle. 72 * In particular, it cannot be called in any of React lifecycle methods like `componentDidMount`. 73 * This limitation is due to the fact that when the application is launched in the background, 74 * we need to spin up your JavaScript app, run your task and then shut down — no views are mounted 75 * in this scenario. 76 * 77 * @param taskName Name of the task. It must be the same as the name you provided when registering the task. 78 * @param taskExecutor A function that will be invoked when the task with given `taskName` is executed. 79 */ 80export declare function defineTask(taskName: string, taskExecutor: TaskManagerTaskExecutor): void; 81/** 82 * Checks whether the task is already defined. 83 * 84 * @param taskName Name of the task. 85 */ 86export declare function isTaskDefined(taskName: string): boolean; 87/** 88 * Determine whether the task is registered. Registered tasks are stored in a persistent storage and 89 * preserved between sessions. 90 * 91 * @param taskName Name of the task. 92 * @returns A promise which fulfills with a `boolean` value whether or not the task with given name 93 * is already registered. 94 */ 95export declare function isTaskRegisteredAsync(taskName: string): Promise<boolean>; 96/** 97 * Retrieves `options` associated with the task, that were passed to the function registering the task 98 * (eg. `Location.startLocationUpdatesAsync`). 99 * 100 * @param taskName Name of the task. 101 * @return A promise which fulfills with the `options` object that was passed while registering task 102 * with given name or `null` if task couldn't be found. 103 */ 104export declare function getTaskOptionsAsync<TaskOptions>(taskName: string): Promise<TaskOptions>; 105/** 106 * Provides information about tasks registered in the app. 107 * 108 * @returns A promise which fulfills with an array of tasks registered in the app. Example: 109 * ```json 110 * [ 111 * { 112 * taskName: 'location-updates-task-name', 113 * taskType: 'location', 114 * options: { 115 * accuracy: Location.Accuracy.High, 116 * showsBackgroundLocationIndicator: false, 117 * }, 118 * }, 119 * { 120 * taskName: 'geofencing-task-name', 121 * taskType: 'geofencing', 122 * options: { 123 * regions: [...], 124 * }, 125 * }, 126 * ] 127 * ``` 128 */ 129export declare function getRegisteredTasksAsync(): Promise<TaskManagerTask[]>; 130/** 131 * Unregisters task from the app, so the app will not be receiving updates for that task anymore. 132 * _It is recommended to use methods specialized by modules that registered the task, eg. 133 * [`Location.stopLocationUpdatesAsync`](./location/#expolocationstoplocationupdatesasynctaskname)._ 134 * 135 * @param taskName Name of the task to unregister. 136 * @return A promise which fulfills as soon as the task is unregistered. 137 */ 138export declare function unregisterTaskAsync(taskName: string): Promise<void>; 139/** 140 * Unregisters all tasks registered for the running app. You may want to call this when the user is 141 * signing out and you no longer need to track his location or run any other background tasks. 142 * @return A promise which fulfills as soon as all tasks are completely unregistered. 143 */ 144export declare function unregisterAllTasksAsync(): Promise<void>; 145/** 146 * Determine if the `TaskManager` API can be used in this app. 147 * @return A promise fulfills with `true` if the API can be used, and `false` otherwise. 148 * On the web it always returns `false`. 149 */ 150export declare function isAvailableAsync(): Promise<boolean>; 151