import { UnavailabilityError } from 'expo-modules-core';

import NotificationScheduler from './NotificationScheduler';

/**
 * Cancels all scheduled notifications.
 * @return A Promise that resolves once all the scheduled notifications are successfully canceled, or if there are no scheduled notifications.
 * @header schedule
 */
export async function cancelAllScheduledNotificationsAsync(): Promise<void> {
  if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) {
    throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync');
  }

  return await NotificationScheduler.cancelAllScheduledNotificationsAsync();
}
