react-native-alarms 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AlarmService.d.ts CHANGED
@@ -1,115 +1,219 @@
1
1
  /**
2
- * AlarmService - High-level alarm management API
3
- * Provides convenient wrapper methods for the native alarm module
2
+ * High-level alarm management API.
3
+ *
4
+ * Provides convenient wrapper methods for managing native alarms,
5
+ * including scheduling, updating, cancelling, snoozing, and monitoring
6
+ * alarm lifecycle events.
7
+ *
8
+ * This service can be used for alarms, scheduled reminders, and other
9
+ * time-sensitive experiences supported by the native alarm module.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { AlarmService } from 'react-native-alarms';
14
+ *
15
+ * const permission = await AlarmService.checkPermission();
16
+ *
17
+ * if (permission.status !== 'granted') {
18
+ * await AlarmService.requestPermission();
19
+ * }
20
+ *
21
+ * const alarmId = await AlarmService.scheduleAlarm({
22
+ * timestamp: Date.now() + 60_000,
23
+ * title: 'Reminder',
24
+ * body: 'Your scheduled reminder is ready.',
25
+ * });
26
+ * ```
4
27
  */
5
28
 
6
29
  import type {
7
30
  AlarmConfig,
8
- Alarm,
31
+ AlarmProp,
9
32
  AlarmPermission,
10
33
  AlarmEvent,
11
- } from './specs/NativeAlarm';
34
+ } from './src/types';
12
35
 
36
+ /**
37
+ * Callback invoked when an alarm lifecycle event occurs.
38
+ *
39
+ * @param alarm - Information about the alarm associated with the event.
40
+ */
13
41
  type AlarmEventListener = (alarm: AlarmEvent) => void;
14
42
 
15
43
  /**
16
- * High-level alarm service for managing alarms
44
+ * Static service for managing native alarms.
45
+ *
46
+ * All methods can be called directly without creating an instance.
17
47
  */
18
48
  export class AlarmService {
19
49
  /**
20
- * Initialize the alarm service and set up event listeners
50
+ * Initializes the alarm service and registers native event listeners.
51
+ *
52
+ * Call this method to begin forwarding native alarm events to
53
+ * registered JavaScript listeners. Event registration methods may
54
+ * also initialize the service automatically.
21
55
  */
22
56
  static initialize(): void;
23
57
 
24
58
  /**
25
- * Cleanup event listeners
59
+ * Removes native event subscriptions created by the service.
60
+ *
61
+ * Registered JavaScript callbacks may remain registered, depending
62
+ * on the implementation. Reinitialize the service before expecting
63
+ * to receive native events again.
26
64
  */
27
65
  static cleanup(): void;
28
66
 
29
67
  /**
30
- * Register a listener for when alarms fire
31
- * @returns unsubscribe function
68
+ * Registers a listener for when an alarm fires.
69
+ *
70
+ * @param listener - Callback invoked with the fired alarm's event data.
71
+ * @returns A function that unregisters this listener.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const unsubscribe = AlarmService.onAlarmFired((alarm) => {
76
+ * console.log('Alarm fired:', alarm);
77
+ * });
78
+ *
79
+ * // Unsubscribe when no longer needed.
80
+ * unsubscribe();
81
+ * ```
32
82
  */
33
83
  static onAlarmFired(listener: AlarmEventListener): () => void;
34
84
 
35
85
  /**
36
- * Register a listener for when alarms are dismissed
37
- * @returns unsubscribe function
86
+ * Registers a listener for when an alarm is dismissed.
87
+ *
88
+ * @param listener - Callback invoked with the dismissed alarm's event data.
89
+ * @returns A function that unregisters this listener.
38
90
  */
39
91
  static onAlarmDismissed(listener: AlarmEventListener): () => void;
40
92
 
41
93
  /**
42
- * Register a listener for when alarms are snoozed
43
- * @returns unsubscribe function
94
+ * Registers a listener for when an alarm is snoozed.
95
+ *
96
+ * @param listener - Callback invoked with the snoozed alarm's event data.
97
+ * @returns A function that unregisters this listener.
44
98
  */
45
99
  static onAlarmSnoozed(listener: AlarmEventListener): () => void;
46
100
 
47
101
  /**
48
- * Check the current alarm permissions
102
+ * Checks the current alarm permission status.
103
+ *
104
+ * @returns A promise resolving to the current permission information.
105
+ * @throws If the native alarm module is unavailable.
49
106
  */
50
107
  static checkPermission(): Promise<AlarmPermission>;
51
108
 
52
109
  /**
53
- * Request alarm permissions
110
+ * Requests the permissions required by the native alarm functionality.
111
+ *
112
+ * @returns A promise resolving to the resulting permission information.
113
+ * @throws If the native alarm module is unavailable.
54
114
  */
55
115
  static requestPermission(): Promise<AlarmPermission>;
56
116
 
57
117
  /**
58
- * Schedule a new alarm
59
- * @returns alarm ID
118
+ * Schedules a new alarm.
119
+ *
120
+ * @param config - Configuration describing the alarm to schedule.
121
+ * @returns A promise resolving to the ID assigned to the scheduled alarm.
122
+ * @throws If the native alarm module is unavailable or scheduling fails.
60
123
  */
61
124
  static scheduleAlarm(config: AlarmConfig): Promise<string>;
62
125
 
63
126
  /**
64
- * Update an existing alarm
65
- * @returns boolean indicating success
127
+ * Updates an existing scheduled alarm.
128
+ *
129
+ * @param alarmId - ID of the alarm to update.
130
+ * @param config - Updated configuration for the alarm.
131
+ * @returns A promise resolving to `true` if the update succeeds.
132
+ * @throws If the native alarm module is unavailable or the update fails.
66
133
  */
67
134
  static updateAlarm(alarmId: string, config: AlarmConfig): Promise<boolean>;
68
135
 
69
136
  /**
70
- * Cancel an alarm
71
- * @returns boolean if alarm existed
137
+ * Cancels a scheduled alarm.
138
+ *
139
+ * @param alarmId - ID of the alarm to cancel.
140
+ * @returns A promise resolving to `true` if the alarm was cancelled.
141
+ * @throws If the native alarm module is unavailable.
72
142
  */
73
143
  static cancelAlarm(alarmId: string): Promise<boolean>;
74
144
 
75
145
  /**
76
- * Cancel all alarms
146
+ * Cancels all scheduled alarms.
147
+ *
148
+ * @returns A promise that resolves when the cancellation operation completes.
149
+ * @throws If the native alarm module is unavailable.
77
150
  */
78
151
  static cancelAllAlarms(): Promise<void>;
79
152
 
80
153
  /**
81
- * Stop the currently ringing alarm
154
+ * Stops a currently ringing alarm.
155
+ *
156
+ * @param alarmId - ID of the ringing alarm to stop.
157
+ * @returns A promise that resolves when the stop operation completes.
158
+ * @throws If the native alarm module is unavailable.
82
159
  */
83
160
  static stopAlarm(alarmId: string): Promise<void>;
84
161
 
85
162
  /**
86
- * Snooze the currently ringing alarm
87
- * @param minutes - snooze duration (defaults to alarm's snoozeMinutes)
163
+ * Snoozes a currently ringing alarm.
164
+ *
165
+ * @param alarmId - ID of the alarm to snooze.
166
+ * @param minutes - Optional snooze duration in minutes. If omitted,
167
+ * the native implementation or alarm configuration determines the default.
168
+ * @returns A promise that resolves when the snooze operation completes.
169
+ * @throws If the native alarm module is unavailable or snoozing fails.
88
170
  */
89
171
  static snoozeAlarm(alarmId: string, minutes?: number): Promise<void>;
90
172
 
91
173
  /**
92
- * Get the currently ringing alarm (if any)
174
+ * Retrieves the currently ringing alarm, if one exists.
175
+ *
176
+ * @returns A promise resolving to the ringing alarm, or `null` if none exists.
177
+ * @throws If the native alarm module is unavailable.
93
178
  */
94
- static getRingingAlarm(): Promise<Alarm | null>;
179
+ static getRingingAlarm(): Promise<AlarmProp | null>;
95
180
 
96
181
  /**
97
- * Get a specific alarm by ID
182
+ * Retrieves a specific alarm by its ID.
183
+ *
184
+ * @param alarmId - ID of the alarm to retrieve.
185
+ * @returns A promise resolving to the alarm, or `null` if it is not found.
186
+ * @throws If the native alarm module is unavailable.
98
187
  */
99
- static getAlarm(alarmId: string): Promise<Alarm | null>;
188
+ static getAlarm(alarmId: string): Promise<AlarmProp | null>;
100
189
 
101
190
  /**
102
- * Get all scheduled alarms
191
+ * Retrieves all alarms known to the native alarm module.
192
+ *
193
+ * @returns A promise resolving to an array of alarm records.
194
+ * @throws If the native alarm module is unavailable.
103
195
  */
104
- static getAllAlarms(): Promise<Alarm[]>;
196
+ static getAllAlarms(): Promise<AlarmProp[]>;
105
197
 
106
198
  /**
107
- * Check if an alarm is scheduled
199
+ * Checks whether an alarm is currently scheduled.
200
+ *
201
+ * @param alarmId - ID of the alarm to check.
202
+ * @returns A promise resolving to `true` if the alarm is scheduled;
203
+ * otherwise, `false`.
204
+ * @throws If the native alarm module is unavailable.
108
205
  */
109
206
  static isScheduled(alarmId: string): Promise<boolean>;
110
207
 
111
208
  /**
112
- * Opens the vendor Autostart screen on Android; resolves false on iOS.
209
+ * Opens the device manufacturer's Auto Start settings on Android,
210
+ * where supported, to help users configure background launch behavior.
211
+ *
212
+ * On iOS, this method resolves to `false`.
213
+ *
214
+ * @returns A promise resolving to `true` if the settings screen was opened;
215
+ * otherwise, `false`.
216
+ * @throws If the native alarm module is unavailable.
113
217
  */
114
218
  static openAutoStartSettings(): Promise<boolean>;
115
219
  }
package/AlarmService.ts CHANGED
@@ -1,31 +1,87 @@
1
1
  /**
2
- * AlarmService - High-level alarm management API
2
+ * High-level alarm management API.
3
3
  *
4
- * This module provides a convenient wrapper around the native alarm module
5
- * with additional features like event listeners and state management.
4
+ * Provides a convenient wrapper around the native `Alarm` module for
5
+ * scheduling and managing alarms, handling permissions, querying alarm
6
+ * state, and subscribing to native alarm events.
7
+ *
8
+ * This API can also be used for time-sensitive reminders and custom
9
+ * scheduled experiences supported by the native alarm presentation flow.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { AlarmService } from 'react-native-alarms/service';
14
+ *
15
+ * const permission = await AlarmService.checkPermission();
16
+ *
17
+ * if (permission.status !== 'granted') {
18
+ * await AlarmService.requestPermission();
19
+ * }
20
+ *
21
+ * const alarmId = await AlarmService.scheduleAlarm({
22
+ * timestamp: Date.now() + 60_000,
23
+ * title: 'Reminder',
24
+ * body: 'Your scheduled event is ready.',
25
+ * });
26
+ * ```
6
27
  */
7
-
8
28
  import { NativeEventEmitter, NativeModules } from 'react-native';
9
29
  import type {
10
30
  AlarmConfig,
11
- Alarm,
31
+ AlarmProp,
12
32
  AlarmPermission,
13
33
  AlarmEvent,
14
- } from './specs/NativeAlarm';
34
+ } from './src/types';
35
+ import { AlarmRegistry } from './src/utils';
15
36
 
16
37
  const { Alarm: NativeAlarm } = NativeModules;
17
38
 
18
- // Guard against module not being linked
39
+ /**
40
+ * Resolves the native alarm module when it is linked.
41
+ *
42
+ * The module is loaded conditionally so importing the service does not
43
+ * immediately fail when the native module is unavailable.
44
+ */
19
45
  const alarm = NativeAlarm ? require('./specs/NativeAlarm').default : null;
20
46
 
47
+ /**
48
+ * Native event emitter used to subscribe to alarm lifecycle events.
49
+ */
21
50
  const alarmEmitter = NativeAlarm ? new NativeEventEmitter(NativeAlarm) : null;
22
51
 
52
+ /**
53
+ * Callback invoked when a native alarm event is received.
54
+ *
55
+ * @param alarm Event data emitted by the native alarm module.
56
+ */
23
57
  type AlarmEventListener = (alarm: AlarmEvent) => void;
24
58
 
25
59
  /**
26
- * High-level alarm service for managing alarms
60
+ * High-level service for scheduling and managing native alarms.
61
+ *
62
+ * All methods are static, so the service can be used directly without
63
+ * creating an instance.
64
+ *
65
+ * The service maintains JavaScript event listeners and forwards events
66
+ * received from the native module to registered callbacks.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const unsubscribe = AlarmService.onAlarmFired((alarm) => {
71
+ * console.log('Alarm fired:', alarm.title);
72
+ * });
73
+ *
74
+ * // Remove this listener when it is no longer needed.
75
+ * unsubscribe();
76
+ * ```
27
77
  */
28
78
  export class AlarmService {
79
+ /**
80
+ * Registered JavaScript listeners grouped by event type.
81
+ *
82
+ * A `Set` prevents the same callback reference from being registered
83
+ * more than once for the same event.
84
+ */
29
85
  private static listeners: {
30
86
  fired: Set<AlarmEventListener>;
31
87
  dismissed: Set<AlarmEventListener>;
@@ -36,12 +92,21 @@ export class AlarmService {
36
92
  snoozed: new Set(),
37
93
  };
38
94
 
95
+ /**
96
+ * Native event subscriptions created by {@link initialize}.
97
+ */
39
98
  private static subscriptions: any[] = [];
40
99
 
41
100
  /**
42
- * Initialize the alarm service and set up event listeners
101
+ * Initializes native event forwarding.
102
+ *
103
+ * Registers listeners for alarm firing, dismissal, and snoozing.
104
+ * Calling this method when subscriptions already exist does not
105
+ * register duplicate native subscriptions.
106
+ *
107
+ * This method is called automatically by the event subscription helpers.
43
108
  */
44
- static initialize() {
109
+ static initialize(): void {
45
110
  if (!alarmEmitter || !this.subscriptions.length) {
46
111
  this.subscriptions = [
47
112
  alarmEmitter?.addListener('onAlarmFired', (data: any) => {
@@ -64,42 +129,76 @@ export class AlarmService {
64
129
  }
65
130
 
66
131
  /**
67
- * Cleanup event listeners
132
+ * Removes native event subscriptions created by the service.
133
+ *
134
+ * This stops forwarding native events to JavaScript listeners until
135
+ * {@link initialize} is called again.
136
+ *
137
+ * Registered JavaScript callbacks remain in their respective sets.
138
+ * Use the unsubscribe functions returned by the event helpers to
139
+ * remove individual callbacks.
68
140
  */
69
- static cleanup() {
141
+ static cleanup(): void {
70
142
  this.subscriptions.forEach(sub => sub?.remove());
71
143
  this.subscriptions = [];
72
144
  }
73
145
 
74
146
  /**
75
- * Register a listener for when alarms fire
147
+ * Subscribes to alarms when they fire.
148
+ *
149
+ * The service initializes native event forwarding automatically.
150
+ *
151
+ * @param listener Callback invoked with the fired alarm's event data.
152
+ * @returns A function that unregisters this callback.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const unsubscribe = AlarmService.onAlarmFired(alarm => {
157
+ * console.log('Fired:', alarm.alarmId, alarm.title);
158
+ * });
159
+ *
160
+ * // Later:
161
+ * unsubscribe();
162
+ * ```
76
163
  */
77
- static onAlarmFired(listener: AlarmEventListener) {
164
+ static onAlarmFired(listener: AlarmEventListener): () => boolean {
78
165
  this.initialize();
79
166
  this.listeners.fired.add(listener);
167
+
80
168
  return () => this.listeners.fired.delete(listener);
81
169
  }
82
170
 
83
171
  /**
84
- * Register a listener for when alarms are dismissed
172
+ * Subscribes to alarms when they are dismissed.
173
+ *
174
+ * @param listener Callback invoked with the dismissed alarm's event data.
175
+ * @returns A function that unregisters this callback.
85
176
  */
86
- static onAlarmDismissed(listener: AlarmEventListener) {
177
+ static onAlarmDismissed(listener: AlarmEventListener): () => boolean {
87
178
  this.initialize();
88
179
  this.listeners.dismissed.add(listener);
180
+
89
181
  return () => this.listeners.dismissed.delete(listener);
90
182
  }
91
183
 
92
184
  /**
93
- * Register a listener for when alarms are snoozed
185
+ * Subscribes to alarms when they are snoozed.
186
+ *
187
+ * @param listener Callback invoked with the snoozed alarm's event data.
188
+ * @returns A function that unregisters this callback.
94
189
  */
95
- static onAlarmSnoozed(listener: AlarmEventListener) {
190
+ static onAlarmSnoozed(listener: AlarmEventListener): () => boolean {
96
191
  this.initialize();
97
192
  this.listeners.snoozed.add(listener);
193
+
98
194
  return () => this.listeners.snoozed.delete(listener);
99
195
  }
100
196
 
101
197
  /**
102
- * Check the current alarm permissions
198
+ * Retrieves the current alarm permission and capability status.
199
+ *
200
+ * @returns A promise resolving to the current permission status.
201
+ * @throws Error if the native alarm module is not linked.
103
202
  */
104
203
  static async checkPermission(): Promise<AlarmPermission> {
105
204
  if (!alarm) throw new Error('Alarm module not linked');
@@ -107,7 +206,12 @@ export class AlarmService {
107
206
  }
108
207
 
109
208
  /**
110
- * Request alarm permissions
209
+ * Requests the permissions required for alarm scheduling.
210
+ *
211
+ * The permissions requested depend on the platform and its capabilities.
212
+ *
213
+ * @returns A promise resolving to the updated permission status.
214
+ * @throws Error if the native alarm module is not linked.
111
215
  */
112
216
  static async requestPermission(): Promise<AlarmPermission> {
113
217
  if (!alarm) throw new Error('Alarm module not linked');
@@ -115,15 +219,42 @@ export class AlarmService {
115
219
  }
116
220
 
117
221
  /**
118
- * Schedule a new alarm
222
+ * Schedules a new alarm or time-based reminder.
223
+ *
224
+ * @param config Configuration containing the trigger timestamp,
225
+ * title, optional message, repeat settings, and custom data.
226
+ * @returns A promise resolving to the scheduled alarm ID.
227
+ * @throws Error if the native alarm module is not linked.
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const alarmId = await AlarmService.scheduleAlarm({
232
+ * timestamp: Date.now() + 5 * 60_000,
233
+ * title: 'Take a break',
234
+ * body: 'Your scheduled break starts now.',
235
+ * data: JSON.stringify({ type: 'break-reminder' }),
236
+ * });
237
+ * ```
119
238
  */
120
239
  static async scheduleAlarm(config: AlarmConfig): Promise<string> {
121
- if (!alarm) throw new Error('Alarm module not linked');
122
- return alarm.scheduleAlarm(config);
240
+ if (!alarm) {
241
+ throw new Error('Alarm module not linked');
242
+ }
243
+ const componentName = AlarmRegistry.resolve(config.presentation?.type);
244
+ return alarm.scheduleAlarm({
245
+ ...config,
246
+ componentName,
247
+ componentProps: config.presentation?.props ?? {},
248
+ });
123
249
  }
124
250
 
125
251
  /**
126
- * Update an existing alarm
252
+ * Updates an existing scheduled alarm.
253
+ *
254
+ * @param alarmId Identifier of the alarm to update.
255
+ * @param config Updated alarm configuration.
256
+ * @returns A promise resolving to `true` if the update succeeds.
257
+ * @throws Error if the native alarm module is not linked.
127
258
  */
128
259
  static async updateAlarm(
129
260
  alarmId: string,
@@ -134,7 +265,11 @@ export class AlarmService {
134
265
  }
135
266
 
136
267
  /**
137
- * Cancel an alarm
268
+ * Cancels a specific scheduled alarm.
269
+ *
270
+ * @param alarmId Identifier of the alarm to cancel.
271
+ * @returns A promise resolving to whether cancellation succeeded.
272
+ * @throws Error if the native alarm module is not linked.
138
273
  */
139
274
  static async cancelAlarm(alarmId: string): Promise<boolean> {
140
275
  if (!alarm) throw new Error('Alarm module not linked');
@@ -142,7 +277,10 @@ export class AlarmService {
142
277
  }
143
278
 
144
279
  /**
145
- * Cancel all alarms
280
+ * Cancels all scheduled alarms managed by the native module.
281
+ *
282
+ * @returns A promise that resolves when the operation completes.
283
+ * @throws Error if the native alarm module is not linked.
146
284
  */
147
285
  static async cancelAllAlarms(): Promise<void> {
148
286
  if (!alarm) throw new Error('Alarm module not linked');
@@ -150,7 +288,11 @@ export class AlarmService {
150
288
  }
151
289
 
152
290
  /**
153
- * Stop the currently ringing alarm
291
+ * Stops a currently ringing alarm.
292
+ *
293
+ * @param alarmId Identifier of the ringing alarm.
294
+ * @returns A promise that resolves when the operation completes.
295
+ * @throws Error if the native alarm module is not linked.
154
296
  */
155
297
  static async stopAlarm(alarmId: string): Promise<void> {
156
298
  if (!alarm) throw new Error('Alarm module not linked');
@@ -158,7 +300,17 @@ export class AlarmService {
158
300
  }
159
301
 
160
302
  /**
161
- * Snooze the currently ringing alarm
303
+ * Snoozes a currently ringing alarm.
304
+ *
305
+ * @param alarmId Identifier of the ringing alarm.
306
+ * @param minutes Snooze duration in minutes. Defaults to `5`.
307
+ * @returns A promise that resolves when the operation completes.
308
+ * @throws Error if the native alarm module is not linked.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * await AlarmService.snoozeAlarm(alarmId, 10);
313
+ * ```
162
314
  */
163
315
  static async snoozeAlarm(alarmId: string, minutes?: number): Promise<void> {
164
316
  if (!alarm) throw new Error('Alarm module not linked');
@@ -166,43 +318,78 @@ export class AlarmService {
166
318
  }
167
319
 
168
320
  /**
169
- * Get the currently ringing alarm (if any)
321
+ * Retrieves the alarm that is currently ringing.
322
+ *
323
+ * @returns A promise resolving to the ringing alarm, or `null`
324
+ * if no alarm is currently ringing.
325
+ * @throws Error if the native alarm module is not linked.
170
326
  */
171
- static async getRingingAlarm(): Promise<Alarm | null> {
327
+ static async getRingingAlarm(): Promise<AlarmProp | null> {
172
328
  if (!alarm) throw new Error('Alarm module not linked');
173
329
  return alarm.getRingingAlarm();
174
330
  }
175
331
 
176
332
  /**
177
- * Get a specific alarm by ID
333
+ * Retrieves a scheduled alarm by its identifier.
334
+ *
335
+ * @param alarmId Identifier of the alarm to retrieve.
336
+ * @returns A promise resolving to the alarm, or `null` if not found.
337
+ * @throws Error if the native alarm module is not linked.
178
338
  */
179
- static async getAlarm(alarmId: string): Promise<Alarm | null> {
339
+ static async getAlarm(alarmId: string): Promise<AlarmProp | null> {
180
340
  if (!alarm) throw new Error('Alarm module not linked');
181
341
  return alarm.getAlarm(alarmId);
182
342
  }
183
343
 
184
344
  /**
185
- * Get all scheduled alarms
345
+ * Retrieves all alarms managed by the native module.
346
+ *
347
+ * @returns A promise resolving to the list of scheduled alarms.
348
+ * @throws Error if the native alarm module is not linked.
186
349
  */
187
- static async getAllAlarms(): Promise<Alarm[]> {
350
+ static async getAllAlarms(): Promise<AlarmProp[]> {
188
351
  if (!alarm) throw new Error('Alarm module not linked');
189
352
  return alarm.getAllAlarms();
190
353
  }
191
354
 
192
355
  /**
193
- * Check if an alarm is scheduled
356
+ * Checks whether an alarm is currently scheduled.
357
+ *
358
+ * @param alarmId Identifier of the alarm to check.
359
+ * @returns A promise resolving to `true` if scheduled, otherwise `false`.
360
+ * @throws Error if the native alarm module is not linked.
194
361
  */
195
362
  static async isScheduled(alarmId: string): Promise<boolean> {
196
363
  if (!alarm) throw new Error('Alarm module not linked');
197
364
  return alarm.isScheduled(alarmId);
198
365
  }
199
366
 
200
- /** Opens the vendor Autostart screen on Android; resolves false on iOS. */
367
+ /**
368
+ * Opens the device manufacturer's Auto Start settings screen.
369
+ *
370
+ * This is primarily intended for Android devices whose manufacturers
371
+ * provide additional background-execution settings.
372
+ *
373
+ * On iOS, the native implementation resolves to `false`.
374
+ *
375
+ * @returns A promise resolving to `true` if the settings screen was
376
+ * opened, or `false` if unsupported or unavailable.
377
+ * @throws Error if the native alarm module is not linked.
378
+ */
201
379
  static async openAutoStartSettings(): Promise<boolean> {
202
380
  if (!alarm) throw new Error('Alarm module not linked');
203
381
  return alarm.openAutoStartSettings();
204
382
  }
205
383
  }
206
384
 
207
- // Export a singleton instance
385
+ /**
386
+ * Default export for convenient service access.
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * import AlarmService from 'react-native-alarms/service';
391
+ *
392
+ * const alarms = await AlarmService.getAllAlarms();
393
+ * ```
394
+ */
208
395
  export default AlarmService;