react-native-alarm-scheduler
API reference

Events

Foreground listeners, and why they are never the whole story.

const subscription = AlarmScheduler.addListener('onAlarmTriggered', (alarm) => {
  console.log(alarm);
});

const actionSubscription = AlarmScheduler.addListener('onAlarmAction', (action) => {
  console.log(action);
});

const stateSubscription = AlarmScheduler.addListener('onAlarmStateChange', (event) => {
  console.log(event);
});

subscription.remove();
actionSubscription.remove();
stateSubscription.remove();

Payloads

type AlarmSchedulerModuleEvents = {
  onAlarmTriggered: (alarm: ScheduledAlarm) => void;
  onAlarmAction: (action: AlarmAction) => void;
  onAlarmStateChange: (event: AlarmStateChange) => void;
};

type AlarmStateChange = {
  id: string;
  occurrenceId?: string;
  relationship?: 'primary' | 'deferred' | 'followUp';
  state: 'scheduled' | 'alerting' | 'countdown' | 'paused';
  timestamp: number;
  metadata?: AlarmMetadata;
};

Events are best effort

They are delivered only when a JS runtime happens to be alive — which, for an alarm that fires at 7am with the app killed, is usually not the case.

Everything the events carry is also persisted natively. The reliable pattern on both platforms is:

  1. Handle the event if it arrives.
  2. Reconcile from getPendingNativeAlarmHandoffAsync(), getPendingAlarmActionsAsync() and getCurrentAlarmContextAsync() on every launch and foreground.

See Handoffs and actions for the full pattern.

On this page