1import { UnavailabilityError } from 'expo-modules-core';
2import BackgroundNotificationTasksModule from './BackgroundNotificationTasksModule.native';
3/**
4 * When a notification is received while the app is backgrounded, using this function you can set a callback that will be run in response to that notification.
5 * Under the hood, this function is run using `expo-task-manager`. You **must** define the task first, with [`TaskManager.defineTask`](./task-manager#taskmanagerdefinetasktaskname-taskexecutor).
6 * Make sure you define it in the global scope.
7 *
8 * The callback function you define with `TaskManager.defineTask` will receive an object with the following fields:
9 * - `data`: The remote payload delivered by either FCM (Android) or APNs (iOS). See [`PushNotificationTrigger`](#pushnotificationtrigger) for details.
10 * - `error`: The error (if any) that occurred during execution of the task.
11 * - `executionInfo`: JSON object of additional info related to the task, including the `taskName`.
12 * @param taskName The string you passed to `TaskManager.defineTask` as the `taskName` parameter.
13 *
14 * @example
15 * ```ts
16 * import * as TaskManager from 'expo-task-manager';
17 * import * as Notifications from 'expo-notifications';
18 *
19 * const BACKGROUND_NOTIFICATION_TASK = 'BACKGROUND-NOTIFICATION-TASK';
20 *
21 * TaskManager.defineTask(BACKGROUND_NOTIFICATION_TASK, ({ data, error, executionInfo }) => {
22 *   console.log('Received a notification in the background!');
23 *   // Do something with the notification data
24 * });
25 *
26 * Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);
27 * ```
28 * @header inBackground
29 */
30export default async function registerTaskAsync(taskName) {
31    if (!BackgroundNotificationTasksModule.registerTaskAsync) {
32        throw new UnavailabilityError('Notifications', 'registerTaskAsync');
33    }
34    return await BackgroundNotificationTasksModule.registerTaskAsync(taskName);
35}
36//# sourceMappingURL=registerTaskAsync.js.map