API reference
Types
Every type exported by the package.
All types are named exports of react-native-alarm-scheduler:
import type {
AlarmScheduleInput,
ScheduledAlarm,
AlarmPermissionResponse,
} from 'react-native-alarm-scheduler';Permissions
type AlarmAuthorizationStatus =
| 'authorized'
| 'denied'
| 'notDetermined'
| 'unavailable'
| 'unknown';
type AlarmPermissionResponse = {
platform: 'android' | 'ios';
status: AlarmAuthorizationStatus;
canScheduleExactAlarms: boolean;
canOpenSettings: boolean;
canUseFullScreenIntent?: boolean;
canPostNotifications?: boolean;
};Alarms
type AlarmWeekday = 1 | 2 | 3 | 4 | 5 | 6 | 7;
type AlarmMetadataValue = string | number | boolean;
type AlarmMetadata = Record<string, AlarmMetadataValue>;
type AlarmOccurrenceRelationship = 'primary' | 'deferred' | 'followUp';
type AlarmScheduleInput = {
id?: string;
hour: number;
minute: number;
title?: string;
weekdays?: AlarmWeekday[];
timestamp?: number;
showUi?: boolean;
soundUri?: string;
ios?: IosAlarmOptions;
android?: AndroidAlarmOptions;
};
type ScheduledAlarm = {
id: string;
occurrenceId?: string;
relationship?: AlarmOccurrenceRelationship;
hour: number;
minute: number;
title: string;
weekdays: AlarmWeekday[];
timestamp: number;
platform: 'android' | 'ios';
metadata?: AlarmMetadata;
};Occurrences
type AlarmOccurrencePhase = 'scheduled' | 'ringing' | 'completed' | 'cancelled';
type AlarmOccurrence = {
occurrenceId: string;
alarmId: string;
parentOccurrenceId?: string;
scheduledFor: number;
relationship: AlarmOccurrenceRelationship;
phase: AlarmOccurrencePhase;
metadata?: AlarmMetadata;
};
type AlarmOccurrenceResolution = {
outcome: 'completed' | 'deferred';
next?: {
delaySeconds: number;
relationship: 'deferred' | 'followUp';
metadata?: AlarmMetadata;
};
idempotencyKey?: string;
};
type AlarmOccurrenceResolutionResult = {
alarmId: string;
resolvedOccurrenceId: string;
outcome: 'completed' | 'deferred';
status: 'resolved' | 'resolvedWithoutNext';
nextOccurrence?: AlarmOccurrence;
};Platform options
type AlarmAlertActionMode =
| 'default'
| 'openAppOnly';
type IosAlarmOptions = {
metadata?: AlarmMetadata;
alertTitle?: string;
alertActionMode?: AlarmAlertActionMode;
stopButtonTitle?: string;
secondaryButtonTitle?: string;
/** Title shown while a deferred or follow-up timer occurrence is counting down. */
countdownTitle?: string;
stopIntentBehavior?: 'recordOnly' | 'openApp' | 'rescheduleImmediate';
secondaryButtonBehavior?: 'openApp' | 'recordOnly' | 'none';
silent?: boolean;
soundUri?: string;
soundName?: string;
};
type AndroidAlarmOptions = {
metadata?: AlarmMetadata;
alertTitle?: string;
alertBody?: string;
alertActionMode?: AlarmAlertActionMode;
stopButtonTitle?: string;
secondaryButtonTitle?: string;
stopIntentBehavior?: 'recordOnly' | 'openApp' | 'rescheduleImmediate';
secondaryButtonBehavior?: 'openApp' | 'recordOnly' | 'none';
silent?: boolean;
soundName?: string;
soundUri?: string;
vibrate?: boolean;
enforceVolume?: boolean;
restoreVolume?: boolean;
volume?: number;
fullScreen?: boolean;
fullScreenTarget?: 'native' | 'app';
launchUri?: string;
maxRingDurationSeconds?: number;
backupDelaySeconds?: number;
};Context and actions
type AlarmContextState = 'scheduled' | 'alerting' | 'countdown' | 'paused';
type AlarmContext = {
id: string;
metadata?: AlarmMetadata;
state?: AlarmContextState;
nativeAlarmId?: string;
occurrenceId?: string;
relationship?: AlarmOccurrenceRelationship;
};
type AlarmActionType = 'nativeStop' | 'secondaryOpen' | 'snooze' | 'dismiss';
type AlarmAction = {
id: string;
alarmId: string;
action: AlarmActionType;
timestamp: number;
foregroundRequested?: boolean;
rescheduled?: boolean;
rescheduledAlarmId?: string;
retryScheduledFor?: number;
backupAlarmId?: string;
backupScheduledFor?: number;
backupDelaySeconds?: number;
/** Android: set on the handoff recorded when the alarm itself started ringing. */
trigger?: boolean;
/** Android: set on the action recorded when a ring hit `maxRingDurationSeconds`. */
timedOut?: boolean;
};
type AlarmStateChange = {
id: string;
occurrenceId?: string;
relationship?: AlarmOccurrenceRelationship;
state: AlarmContextState;
timestamp: number;
metadata?: AlarmMetadata;
};Backup and debug
type NativeAlarmBackupResult = {
alarmId: string;
backupAlarmId: string;
scheduled: boolean;
scheduledFor?: number;
delaySeconds: number;
};
type NativeAlarmDebugState = {
alarmId: string;
isComplete: boolean;
activeRetryAlarmIds: string[];
pendingActions: AlarmAction[];
pendingHandoff?: AlarmAction | null;
intentDebugCounts?: Record<string, number>;
currentContext: AlarmContext | null;
alertActionMode?: 'default' | 'openAppOnly';
stopButtonIncluded?: boolean;
secondaryButtonIncluded?: boolean;
secondaryButtonBehavior?: 'openApp' | 'recordOnly' | 'none';
stopIntentBehavior?: 'recordOnly' | 'openApp' | 'rescheduleImmediate';
alertInitializer?: 'secondaryOnly' | 'legacyStopButton' | 'androidRingService';
runtimeSupportsSecondaryOnlyAlert?: boolean;
sound?: 'default' | 'named' | 'silent';
soundName?: string;
soundFallbackReason?: 'iosSimulatorCustomSoundUnsupported';
soundUri?: string;
isRinging?: boolean;
isScheduled?: boolean;
canUseFullScreenIntent?: boolean;
canScheduleExactAlarms?: boolean;
};Events
type AlarmSchedulerModuleEvents = {
onAlarmTriggered: (alarm: ScheduledAlarm) => void;
onAlarmAction: (action: AlarmAction) => void;
onAlarmStateChange: (event: AlarmStateChange) => void;
};