1import { UnavailabilityError, uuid } from 'expo-modules-core'; 2 3import NotificationPresenter from './NotificationPresenterModule'; 4import { NotificationContentInput } from './Notifications.types'; 5 6let warningMessageShown = false; 7 8/** 9 * Schedules a notification for immediate trigger. 10 * @param content An object representing the notification content. 11 * @param identifier 12 * @return It returns a Promise resolving with the notification's identifier once the notification is successfully scheduled for immediate display. 13 * @header schedule 14 * @deprecated This method has been deprecated in favor of using an explicit `NotificationHandler` and the [`scheduleNotificationAsync`](#notificationsschedulenotificationasyncrequest) method. More information can be found in our [FYI document](https://expo.fyi/presenting-notifications-deprecated). 15 */ 16export default async function presentNotificationAsync( 17 content: NotificationContentInput, 18 identifier: string = uuid.v4() 19): Promise<string> { 20 if (__DEV__ && !warningMessageShown) { 21 console.warn( 22 '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.' 23 ); 24 warningMessageShown = true; 25 } 26 27 if (!NotificationPresenter.presentNotificationAsync) { 28 throw new UnavailabilityError('Notifications', 'presentNotificationAsync'); 29 } 30 31 return await NotificationPresenter.presentNotificationAsync(identifier, content); 32} 33