1import { UnavailabilityError } from 'expo-modules-core';
2
3import NotificationCategoriesModule from './NotificationCategoriesModule.native';
4import {
5  NotificationCategory,
6  NotificationAction,
7  NotificationCategoryOptions,
8} from './Notifications.types';
9
10/**
11 * Sets the new notification category.
12 * @param identifier A string to associate as the ID of this category. You will pass this string in as the `categoryIdentifier`
13 * in your [`NotificationContent`](#notificationcontent) to associate a notification with this category.
14 * > Don't use the characters `:` or `-` in your category identifier. If you do, categories might not work as expected.
15 * @param actions An array of [`NotificationAction`s](#notificationaction), which describe the actions associated with this category.
16 * @param options An optional object of additional configuration options for your category.
17 * @return A Promise which resolves to the category you just have created.
18 * @platform android
19 * @platform ios
20 * @header categories
21 */
22export default async function setNotificationCategoryAsync(
23  identifier: string,
24  actions: NotificationAction[],
25  options?: NotificationCategoryOptions
26): Promise<NotificationCategory> {
27  if (!NotificationCategoriesModule.setNotificationCategoryAsync) {
28    throw new UnavailabilityError('Notifications', 'setNotificationCategoryAsync');
29  }
30
31  return await NotificationCategoriesModule.setNotificationCategoryAsync(
32    identifier,
33    actions,
34    options
35  );
36}
37