react-native-alarms 0.0.5 → 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/.husky/commit-msg +1 -0
- package/.husky/pre-commit +0 -0
- package/AGENTS.md +291 -0
- package/AlarmService.d.ts +141 -32
- package/AlarmService.ts +238 -39
- package/LICENSE.md +21 -0
- package/README.md +159 -9
- package/android/app/src/main/java/com/reactnativealarm/alarm/AlarmData.kt +154 -8
- package/android/app/src/main/java/com/reactnativealarm/alarm/AlarmModule.kt +2 -2
- package/android/app/src/main/java/com/reactnativealarm/alarm/AlarmRingActivity.kt +3 -2
- package/android/local.properties +8 -0
- package/commitlint.config.mjs +1 -0
- package/index.d.ts +3 -3
- package/index.ts +5 -5
- package/ios/alarm/AlarmData.swift +20 -6
- package/ios/alarm/AlarmKitBackend.swift +43 -40
- package/ios/alarm/AlarmModule.swift +68 -64
- package/ios/alarm/AlarmRingPresenter.swift +26 -19
- package/ios/alarm/AlarmStore.swift +9 -9
- package/ios/alarm/NotificationBackend.swift +33 -33
- package/package.json +5 -2
- package/specs/NativeAlarm.ts +120 -71
- package/src/assets/recording.mp4 +0 -0
- package/src/assets/sample-1.png +0 -0
- package/src/assets/sample-2.png +0 -0
- package/src/assets/sample-3.png +0 -0
- package/src/screens/index.ts +0 -0
- package/src/types/index.ts +246 -0
- package/src/utils/AlarmRegistry.ts +57 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit $1
|
|
File without changes
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
`react-native-alarms` is a React Native library designed to provide reliable alarm functionality across Android and iOS.
|
|
6
|
+
|
|
7
|
+
The library may include JavaScript/TypeScript APIs, native Android and iOS implementations, alarm scheduling, notifications, event handling, and custom alarm interfaces.
|
|
8
|
+
|
|
9
|
+
The primary goals are:
|
|
10
|
+
|
|
11
|
+
- Reliability across supported platforms and operating-system versions.
|
|
12
|
+
- Predictable alarm scheduling, cancellation, and lifecycle behavior.
|
|
13
|
+
- Efficient resource and battery usage.
|
|
14
|
+
- A consistent developer experience for React Native applications.
|
|
15
|
+
- Backward compatibility and maintainable native code.
|
|
16
|
+
|
|
17
|
+
**Important:** Treat the existing implementation and documented behavior as the source of truth. Do not assume that a feature is supported on both platforms until you have verified the implementation.
|
|
18
|
+
|
|
19
|
+
## Instructions for AI Coding Agents
|
|
20
|
+
|
|
21
|
+
Before making changes:
|
|
22
|
+
|
|
23
|
+
1. Inspect the repository structure and `package.json`.
|
|
24
|
+
2. Read `README.md`, `CONTRIBUTING.md`, and relevant documentation.
|
|
25
|
+
3. Inspect the existing implementation before proposing a replacement.
|
|
26
|
+
4. Identify whether the requested change affects JavaScript/TypeScript, Android, iOS, or multiple layers.
|
|
27
|
+
5. Review related tests, configuration files, and existing patches.
|
|
28
|
+
6. Understand the expected behavior and platform-specific constraints before editing code.
|
|
29
|
+
|
|
30
|
+
Do not make broad or unrelated changes when a focused fix is sufficient.
|
|
31
|
+
|
|
32
|
+
### General Rules
|
|
33
|
+
|
|
34
|
+
- Preserve existing project conventions and architecture.
|
|
35
|
+
- Keep changes small, focused, and easy to review.
|
|
36
|
+
- Prefer existing dependencies and utilities over introducing new ones.
|
|
37
|
+
- Avoid unnecessary public API changes.
|
|
38
|
+
- Preserve TypeScript type safety.
|
|
39
|
+
- Handle errors and edge cases explicitly.
|
|
40
|
+
- Do not silently swallow errors.
|
|
41
|
+
- Do not modify generated files unless required by the project's build process.
|
|
42
|
+
- Never commit secrets, credentials, signing keys, or local environment files.
|
|
43
|
+
- Do not claim a test, build, or device scenario passed unless it was actually verified.
|
|
44
|
+
- Clearly identify any behavior that remains untested.
|
|
45
|
+
|
|
46
|
+
## Repository Exploration
|
|
47
|
+
|
|
48
|
+
Before changing files, inspect the available project scripts and directory layout.
|
|
49
|
+
|
|
50
|
+
Useful commands:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cat package.json
|
|
54
|
+
find . -maxdepth 3 -type f | sort
|
|
55
|
+
git status --short
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Review the repository's actual structure rather than assuming specific directories, frameworks, or build commands exist.
|
|
59
|
+
|
|
60
|
+
Do not overwrite user changes or discard uncommitted work.
|
|
61
|
+
|
|
62
|
+
## JavaScript and TypeScript Guidelines
|
|
63
|
+
|
|
64
|
+
- Follow the existing formatting and naming conventions.
|
|
65
|
+
- Use explicit types for public APIs and event payloads.
|
|
66
|
+
- Keep platform-independent business logic separate from native implementation details.
|
|
67
|
+
- Validate inputs before invoking native modules.
|
|
68
|
+
- Maintain consistent error handling.
|
|
69
|
+
- Clean up event subscriptions and listeners when no longer required.
|
|
70
|
+
- Avoid memory leaks, duplicated listeners, and unnecessary re-renders.
|
|
71
|
+
- Document public methods, configuration options, and callbacks.
|
|
72
|
+
|
|
73
|
+
### Public API Compatibility
|
|
74
|
+
|
|
75
|
+
Before changing an exported method, event, property, or type:
|
|
76
|
+
|
|
77
|
+
1. Search for all usages in the repository.
|
|
78
|
+
2. Review the documented public API.
|
|
79
|
+
3. Check whether existing consumers could be affected.
|
|
80
|
+
4. Add or update tests.
|
|
81
|
+
5. Document any breaking changes and migration steps.
|
|
82
|
+
|
|
83
|
+
Do not rename or remove public exports without a clear requirement.
|
|
84
|
+
|
|
85
|
+
## Android Development Guidelines
|
|
86
|
+
|
|
87
|
+
When modifying Android native code:
|
|
88
|
+
|
|
89
|
+
- Follow the existing Java or Kotlin conventions used by the project.
|
|
90
|
+
- Respect Android application and activity lifecycle requirements.
|
|
91
|
+
- Check the minimum SDK and supported Android versions before using APIs.
|
|
92
|
+
- Handle notification and exact-alarm permissions where applicable.
|
|
93
|
+
- Respect Android background-execution and battery-management restrictions.
|
|
94
|
+
- Avoid unnecessary wake locks and background resource consumption.
|
|
95
|
+
- Ensure pending intents and alarm identifiers behave predictably.
|
|
96
|
+
- Handle cancellation, rescheduling, and duplicate requests correctly.
|
|
97
|
+
- Clean up receivers, callbacks, and other resources when appropriate.
|
|
98
|
+
- Follow applicable Android security and platform policies.
|
|
99
|
+
|
|
100
|
+
### Android Alarm Behavior
|
|
101
|
+
|
|
102
|
+
When modifying alarm scheduling or delivery, consider:
|
|
103
|
+
|
|
104
|
+
- Scheduling and cancellation.
|
|
105
|
+
- Repeated alarms.
|
|
106
|
+
- Device reboot behavior, if supported.
|
|
107
|
+
- Application foreground and background states.
|
|
108
|
+
- Process termination.
|
|
109
|
+
- Notification delivery.
|
|
110
|
+
- Full-screen intent restrictions and permissions.
|
|
111
|
+
- Doze mode and battery optimization.
|
|
112
|
+
- Android version and manufacturer differences.
|
|
113
|
+
|
|
114
|
+
Do not promise guaranteed delivery under every system condition. Verify the actual implementation and account for platform restrictions.
|
|
115
|
+
|
|
116
|
+
## iOS Development Guidelines
|
|
117
|
+
|
|
118
|
+
When modifying iOS native code:
|
|
119
|
+
|
|
120
|
+
- Follow the existing Swift or Objective-C conventions.
|
|
121
|
+
- Respect UIKit and application lifecycle requirements.
|
|
122
|
+
- Use the deployment target defined by the project.
|
|
123
|
+
- Handle notification authorization and scheduling correctly.
|
|
124
|
+
- Manage observers, callbacks, timers, and native resources safely.
|
|
125
|
+
- Avoid retain cycles and resource leaks.
|
|
126
|
+
- Handle app foreground and background transitions.
|
|
127
|
+
- Preserve compatibility with supported iOS versions.
|
|
128
|
+
- Respect system restrictions on background execution and alarm-like behavior.
|
|
129
|
+
|
|
130
|
+
### iOS Alarm Behavior
|
|
131
|
+
|
|
132
|
+
When working on alarm functionality, consider:
|
|
133
|
+
|
|
134
|
+
- Alarm scheduling and cancellation.
|
|
135
|
+
- Notification authorization.
|
|
136
|
+
- Application lifecycle transitions.
|
|
137
|
+
- Audio session configuration, where applicable.
|
|
138
|
+
- Repeated alarms and rescheduling.
|
|
139
|
+
- Device restart behavior, where supported.
|
|
140
|
+
- System-managed alarm capabilities, where available.
|
|
141
|
+
- Custom alarm interfaces and their presentation constraints.
|
|
142
|
+
|
|
143
|
+
Do not assume an application can execute arbitrary code or present a custom interface while suspended or terminated. Verify platform capabilities and use supported APIs.
|
|
144
|
+
|
|
145
|
+
## Cross-Platform Behavior
|
|
146
|
+
|
|
147
|
+
Android and iOS do not provide identical capabilities.
|
|
148
|
+
|
|
149
|
+
When implementing a cross-platform feature:
|
|
150
|
+
|
|
151
|
+
1. Define the expected public API.
|
|
152
|
+
2. Identify platform-specific behavior.
|
|
153
|
+
3. Implement each platform using its supported mechanisms.
|
|
154
|
+
4. Return consistent results where practical.
|
|
155
|
+
5. Document differences and limitations.
|
|
156
|
+
6. Test both platforms when the change affects shared behavior.
|
|
157
|
+
|
|
158
|
+
Never simulate unsupported operating-system guarantees through misleading documentation or API responses.
|
|
159
|
+
|
|
160
|
+
## Event and Lifecycle Management
|
|
161
|
+
|
|
162
|
+
For alarm-related events and callbacks:
|
|
163
|
+
|
|
164
|
+
- Preserve the documented event names and payload structure.
|
|
165
|
+
- Avoid firing the same event multiple times for one logical transition.
|
|
166
|
+
- Ensure cancellation and dismissal are handled consistently.
|
|
167
|
+
- Clean up native and JavaScript listeners appropriately.
|
|
168
|
+
- Avoid race conditions between scheduling, firing, dismissal, and snoozing.
|
|
169
|
+
- Ensure callbacks do not unintentionally retain obsolete objects.
|
|
170
|
+
- Consider repeated initialization and application lifecycle transitions.
|
|
171
|
+
|
|
172
|
+
Test event sequences, not just individual callbacks.
|
|
173
|
+
|
|
174
|
+
## Dependencies and Configuration
|
|
175
|
+
|
|
176
|
+
Before adding or upgrading dependencies:
|
|
177
|
+
|
|
178
|
+
- Verify React Native compatibility.
|
|
179
|
+
- Review peer dependencies.
|
|
180
|
+
- Check Android and iOS requirements.
|
|
181
|
+
- Consider bundle size and runtime overhead.
|
|
182
|
+
- Avoid unnecessary native dependencies.
|
|
183
|
+
- Update lockfiles when required by the project's package manager.
|
|
184
|
+
- Document any additional setup steps.
|
|
185
|
+
|
|
186
|
+
Do not change the package manager or lockfile format without a clear reason.
|
|
187
|
+
|
|
188
|
+
## Testing Requirements
|
|
189
|
+
|
|
190
|
+
Inspect `package.json` and existing project configuration to determine which checks are available.
|
|
191
|
+
|
|
192
|
+
Run the applicable checks before completing a change, such as:
|
|
193
|
+
|
|
194
|
+
- Linting.
|
|
195
|
+
- Type checking.
|
|
196
|
+
- Unit tests.
|
|
197
|
+
- Example application builds.
|
|
198
|
+
- Android native compilation.
|
|
199
|
+
- iOS native compilation.
|
|
200
|
+
- Manual device or emulator tests.
|
|
201
|
+
|
|
202
|
+
Do not invent npm scripts or assume a test framework is installed.
|
|
203
|
+
|
|
204
|
+
### Alarm-Specific Test Scenarios
|
|
205
|
+
|
|
206
|
+
Where relevant, verify:
|
|
207
|
+
|
|
208
|
+
- Creating and scheduling an alarm.
|
|
209
|
+
- Cancelling a scheduled alarm.
|
|
210
|
+
- Rescheduling an existing alarm.
|
|
211
|
+
- Handling duplicate scheduling requests.
|
|
212
|
+
- Triggering the correct event.
|
|
213
|
+
- Dismissing and snoozing alarms.
|
|
214
|
+
- Handling denied permissions.
|
|
215
|
+
- Managing foreground and background transitions.
|
|
216
|
+
- Releasing resources and event listeners.
|
|
217
|
+
- Handling supported reboot and process-restart scenarios.
|
|
218
|
+
|
|
219
|
+
Test on real devices when system-level behavior cannot be reliably validated in a simulator.
|
|
220
|
+
|
|
221
|
+
If only one platform is tested, state which platform remains unverified.
|
|
222
|
+
|
|
223
|
+
## Build and Debugging
|
|
224
|
+
|
|
225
|
+
When investigating build failures:
|
|
226
|
+
|
|
227
|
+
1. Capture the complete error message.
|
|
228
|
+
2. Identify the failing project, target, task, or script.
|
|
229
|
+
3. Determine whether the failure is caused by the current change or the existing environment.
|
|
230
|
+
4. Make the smallest appropriate fix.
|
|
231
|
+
5. Re-run the failing check.
|
|
232
|
+
6. Inspect the final diff.
|
|
233
|
+
|
|
234
|
+
Avoid destructive cleanup commands unless necessary. Never delete project files, signing configuration, or user changes simply to make a build pass.
|
|
235
|
+
|
|
236
|
+
## Documentation Requirements
|
|
237
|
+
|
|
238
|
+
Update documentation whenever a change affects:
|
|
239
|
+
|
|
240
|
+
- Installation or native setup.
|
|
241
|
+
- Public methods and configuration options.
|
|
242
|
+
- Permissions or platform requirements.
|
|
243
|
+
- Supported operating-system versions.
|
|
244
|
+
- Events and callback payloads.
|
|
245
|
+
- Alarm scheduling semantics.
|
|
246
|
+
- Known limitations.
|
|
247
|
+
- Troubleshooting instructions.
|
|
248
|
+
|
|
249
|
+
Examples must match the actual implementation.
|
|
250
|
+
|
|
251
|
+
## Git and Code Review
|
|
252
|
+
|
|
253
|
+
Before committing changes:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
git status --short
|
|
257
|
+
git diff --check
|
|
258
|
+
git diff
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Follow the commit conventions in `CONTRIBUTING.md`.
|
|
262
|
+
|
|
263
|
+
Prefer focused commits and pull requests. Do not rewrite Git history, force-push, or amend existing commits unless explicitly requested.
|
|
264
|
+
|
|
265
|
+
Never include unrelated changes in a pull request.
|
|
266
|
+
|
|
267
|
+
## Security and Privacy
|
|
268
|
+
|
|
269
|
+
- Do not hardcode credentials or API keys.
|
|
270
|
+
- Do not log sensitive information unnecessarily.
|
|
271
|
+
- Validate data crossing the JavaScript/native boundary.
|
|
272
|
+
- Use appropriate Android permissions and iOS authorization mechanisms.
|
|
273
|
+
- Follow platform security requirements.
|
|
274
|
+
- Report security-sensitive issues through the repository's designated private reporting channel.
|
|
275
|
+
|
|
276
|
+
## Completion Checklist
|
|
277
|
+
|
|
278
|
+
Before declaring a task complete:
|
|
279
|
+
|
|
280
|
+
- [ ] The requested behavior is implemented.
|
|
281
|
+
- [ ] Existing functionality and public APIs are preserved where possible.
|
|
282
|
+
- [ ] Relevant platform-specific requirements are respected.
|
|
283
|
+
- [ ] Tests or builds have been run where available.
|
|
284
|
+
- [ ] Changes have been reviewed with `git diff`.
|
|
285
|
+
- [ ] Documentation has been updated where needed.
|
|
286
|
+
- [ ] Limitations and untested scenarios are clearly stated.
|
|
287
|
+
- [ ] No unrelated changes, credentials, or generated artifacts were added.
|
|
288
|
+
|
|
289
|
+
## Final Response Requirements
|
|
290
|
+
|
|
291
|
+
When reporting completed
|
package/AlarmService.d.ts
CHANGED
|
@@ -1,112 +1,221 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
-
|
|
31
|
+
AlarmProp,
|
|
9
32
|
AlarmPermission,
|
|
10
33
|
AlarmEvent,
|
|
11
|
-
} from './
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
-
*
|
|
37
|
-
*
|
|
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
|
-
*
|
|
43
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
59
|
-
*
|
|
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
|
-
*
|
|
65
|
-
*
|
|
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
|
-
*
|
|
71
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
87
|
-
*
|
|
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
|
-
*
|
|
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<
|
|
179
|
+
static getRingingAlarm(): Promise<AlarmProp | null>;
|
|
95
180
|
|
|
96
181
|
/**
|
|
97
|
-
*
|
|
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<
|
|
188
|
+
static getAlarm(alarmId: string): Promise<AlarmProp | null>;
|
|
100
189
|
|
|
101
190
|
/**
|
|
102
|
-
*
|
|
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<
|
|
196
|
+
static getAllAlarms(): Promise<AlarmProp[]>;
|
|
105
197
|
|
|
106
198
|
/**
|
|
107
|
-
*
|
|
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>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
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.
|
|
217
|
+
*/
|
|
218
|
+
static openAutoStartSettings(): Promise<boolean>;
|
|
110
219
|
}
|
|
111
220
|
|
|
112
221
|
export default AlarmService;
|