@capgo/capacitor-alarm 8.0.7 → 8.1.0
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/README.md +34 -12
- package/android/src/main/java/app/capgo/capacitor/alarm/CapgoAlarmPlugin.java +9 -1
- package/dist/docs.json +46 -4
- package/dist/esm/definitions.d.ts +24 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoAlarmPlugin/AlarmKitBridge.swift +117 -37
- package/ios/Sources/CapgoAlarmPlugin/CapgoAlarmPlugin.swift +19 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# @capgo/capacitor-alarm
|
|
2
|
-
|
|
2
|
+
<a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-alarm" alt="Capgo - Instant updates for Capacitor" /></a>
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
5
5
|
<h2><a href="https://capgo.app/?ref=plugin_alarm"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
@@ -65,6 +65,7 @@ If your native runtime ships an older build of this plugin that predates the `ch
|
|
|
65
65
|
* [`checkPermissions()`](#checkpermissions)
|
|
66
66
|
* [`getPluginVersion()`](#getpluginversion)
|
|
67
67
|
* [`getAlarms()`](#getalarms)
|
|
68
|
+
* [`cancelAlarm(...)`](#cancelalarm)
|
|
68
69
|
* [Interfaces](#interfaces)
|
|
69
70
|
* [Type Aliases](#type-aliases)
|
|
70
71
|
|
|
@@ -193,6 +194,26 @@ as the system does not provide an API to query alarms.
|
|
|
193
194
|
--------------------
|
|
194
195
|
|
|
195
196
|
|
|
197
|
+
### cancelAlarm(...)
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
cancelAlarm(options: { id: string; }) => Promise<NativeActionResult>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Cancel a scheduled alarm by its ID.
|
|
204
|
+
On iOS 26+, removes the alarm from AlarmKit. On Android/web, returns not supported.
|
|
205
|
+
|
|
206
|
+
| Param | Type | Description |
|
|
207
|
+
| ------------- | ---------------------------- | ------------------------------------------- |
|
|
208
|
+
| **`options`** | <code>{ id: string; }</code> | - Options containing the alarm ID to cancel |
|
|
209
|
+
|
|
210
|
+
**Returns:** <code>Promise<<a href="#nativeactionresult">NativeActionResult</a>></code>
|
|
211
|
+
|
|
212
|
+
**Since:** 8.1.0
|
|
213
|
+
|
|
214
|
+
--------------------
|
|
215
|
+
|
|
216
|
+
|
|
196
217
|
### Interfaces
|
|
197
218
|
|
|
198
219
|
|
|
@@ -200,10 +221,11 @@ as the system does not provide an API to query alarms.
|
|
|
200
221
|
|
|
201
222
|
Result of a native action.
|
|
202
223
|
|
|
203
|
-
| Prop | Type | Description
|
|
204
|
-
| ------------- | -------------------- |
|
|
205
|
-
| **`success`** | <code>boolean</code> | Whether the action was successful
|
|
206
|
-
| **`message`** | <code>string</code> | Optional message with additional information
|
|
224
|
+
| Prop | Type | Description |
|
|
225
|
+
| ------------- | -------------------- | -------------------------------------------------- |
|
|
226
|
+
| **`success`** | <code>boolean</code> | Whether the action was successful |
|
|
227
|
+
| **`message`** | <code>string</code> | Optional message with additional information |
|
|
228
|
+
| **`id`** | <code>string</code> | Optional alarm ID (returned by createAlarm on iOS) |
|
|
207
229
|
|
|
208
230
|
|
|
209
231
|
#### NativeAlarmCreateOptions
|
|
@@ -247,13 +269,13 @@ Result of a permissions request.
|
|
|
247
269
|
|
|
248
270
|
Information about a scheduled alarm.
|
|
249
271
|
|
|
250
|
-
| Prop | Type | Description
|
|
251
|
-
| ------------- | -------------------- |
|
|
252
|
-
| **`id`** | <code>string</code> | Unique identifier for the alarm
|
|
253
|
-
| **`hour`** | <code>number</code> | Hour of day in 24h format (0-23) |
|
|
254
|
-
| **`minute`** | <code>number</code> | Minute of hour (0-59) |
|
|
255
|
-
| **`label`** | <code>string</code> | Optional label for the alarm
|
|
256
|
-
| **`enabled`** | <code>boolean</code> | Whether the alarm is enabled
|
|
272
|
+
| Prop | Type | Description |
|
|
273
|
+
| ------------- | -------------------- | --------------------------------------------------------------------------------------- |
|
|
274
|
+
| **`id`** | <code>string</code> | Unique identifier for the alarm |
|
|
275
|
+
| **`hour`** | <code>number</code> | Hour of day in 24h format (0-23). May be absent for alarms created outside this plugin. |
|
|
276
|
+
| **`minute`** | <code>number</code> | Minute of hour (0-59). May be absent for alarms created outside this plugin. |
|
|
277
|
+
| **`label`** | <code>string</code> | Optional label for the alarm |
|
|
278
|
+
| **`enabled`** | <code>boolean</code> | Whether the alarm is enabled |
|
|
257
279
|
|
|
258
280
|
|
|
259
281
|
### Type Aliases
|
|
@@ -15,7 +15,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
15
15
|
@CapacitorPlugin(name = "CapgoAlarm")
|
|
16
16
|
public class CapgoAlarmPlugin extends Plugin {
|
|
17
17
|
|
|
18
|
-
private final String pluginVersion = "8.0
|
|
18
|
+
private final String pluginVersion = "8.1.0";
|
|
19
19
|
private static final String TAG = "CapgoAlarmPlugin";
|
|
20
20
|
|
|
21
21
|
// ===== Native OS Alarm helpers (Android) =====
|
|
@@ -171,4 +171,12 @@ public class CapgoAlarmPlugin extends Plugin {
|
|
|
171
171
|
ret.put("alarms", new org.json.JSONArray());
|
|
172
172
|
call.resolve(ret);
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
@PluginMethod
|
|
176
|
+
public void cancelAlarm(PluginCall call) {
|
|
177
|
+
JSObject ret = new JSObject();
|
|
178
|
+
ret.put("success", false);
|
|
179
|
+
ret.put("message", "Cancel alarm is not supported on Android");
|
|
180
|
+
call.resolve(ret);
|
|
181
|
+
}
|
|
174
182
|
}
|
package/dist/docs.json
CHANGED
|
@@ -227,6 +227,41 @@
|
|
|
227
227
|
"AlarmInfo"
|
|
228
228
|
],
|
|
229
229
|
"slug": "getalarms"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "cancelAlarm",
|
|
233
|
+
"signature": "(options: { id: string; }) => Promise<NativeActionResult>",
|
|
234
|
+
"parameters": [
|
|
235
|
+
{
|
|
236
|
+
"name": "options",
|
|
237
|
+
"docs": "- Options containing the alarm ID to cancel",
|
|
238
|
+
"type": "{ id: string; }"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"returns": "Promise<NativeActionResult>",
|
|
242
|
+
"tags": [
|
|
243
|
+
{
|
|
244
|
+
"name": "param",
|
|
245
|
+
"text": "options - Options containing the alarm ID to cancel"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": "returns",
|
|
249
|
+
"text": "Promise resolving with the result of the action"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"name": "since",
|
|
253
|
+
"text": "8.1.0"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": "example",
|
|
257
|
+
"text": "```typescript\nconst result = await CapgoAlarm.cancelAlarm({ id: 'alarm-uuid-here' });\nif (result.success) {\n console.log('Alarm cancelled');\n}\n```"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"docs": "Cancel a scheduled alarm by its ID.\nOn iOS 26+, removes the alarm from AlarmKit. On Android/web, returns not supported.",
|
|
261
|
+
"complexTypes": [
|
|
262
|
+
"NativeActionResult"
|
|
263
|
+
],
|
|
264
|
+
"slug": "cancelalarm"
|
|
230
265
|
}
|
|
231
266
|
],
|
|
232
267
|
"properties": []
|
|
@@ -257,6 +292,13 @@
|
|
|
257
292
|
"docs": "Optional message with additional information",
|
|
258
293
|
"complexTypes": [],
|
|
259
294
|
"type": "string | undefined"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"name": "id",
|
|
298
|
+
"tags": [],
|
|
299
|
+
"docs": "Optional alarm ID (returned by createAlarm on iOS)",
|
|
300
|
+
"complexTypes": [],
|
|
301
|
+
"type": "string | undefined"
|
|
260
302
|
}
|
|
261
303
|
]
|
|
262
304
|
},
|
|
@@ -417,16 +459,16 @@
|
|
|
417
459
|
{
|
|
418
460
|
"name": "hour",
|
|
419
461
|
"tags": [],
|
|
420
|
-
"docs": "Hour of day in 24h format (0-23)",
|
|
462
|
+
"docs": "Hour of day in 24h format (0-23). May be absent for alarms created outside this plugin.",
|
|
421
463
|
"complexTypes": [],
|
|
422
|
-
"type": "number"
|
|
464
|
+
"type": "number | undefined"
|
|
423
465
|
},
|
|
424
466
|
{
|
|
425
467
|
"name": "minute",
|
|
426
468
|
"tags": [],
|
|
427
|
-
"docs": "Minute of hour (0-59)",
|
|
469
|
+
"docs": "Minute of hour (0-59). May be absent for alarms created outside this plugin.",
|
|
428
470
|
"complexTypes": [],
|
|
429
|
-
"type": "number"
|
|
471
|
+
"type": "number | undefined"
|
|
430
472
|
},
|
|
431
473
|
{
|
|
432
474
|
"name": "label",
|
|
@@ -25,6 +25,8 @@ export interface NativeActionResult {
|
|
|
25
25
|
success: boolean;
|
|
26
26
|
/** Optional message with additional information */
|
|
27
27
|
message?: string;
|
|
28
|
+
/** Optional alarm ID (returned by createAlarm on iOS) */
|
|
29
|
+
id?: string;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Information about a scheduled alarm.
|
|
@@ -34,10 +36,10 @@ export interface NativeActionResult {
|
|
|
34
36
|
export interface AlarmInfo {
|
|
35
37
|
/** Unique identifier for the alarm */
|
|
36
38
|
id: string;
|
|
37
|
-
/** Hour of day in 24h format (0-23) */
|
|
38
|
-
hour
|
|
39
|
-
/** Minute of hour (0-59) */
|
|
40
|
-
minute
|
|
39
|
+
/** Hour of day in 24h format (0-23). May be absent for alarms created outside this plugin. */
|
|
40
|
+
hour?: number;
|
|
41
|
+
/** Minute of hour (0-59). May be absent for alarms created outside this plugin. */
|
|
42
|
+
minute?: number;
|
|
41
43
|
/** Optional label for the alarm */
|
|
42
44
|
label?: string;
|
|
43
45
|
/** Whether the alarm is enabled */
|
|
@@ -202,4 +204,22 @@ export interface CapgoAlarmPlugin {
|
|
|
202
204
|
alarms: AlarmInfo[];
|
|
203
205
|
message?: string;
|
|
204
206
|
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Cancel a scheduled alarm by its ID.
|
|
209
|
+
* On iOS 26+, removes the alarm from AlarmKit. On Android/web, returns not supported.
|
|
210
|
+
*
|
|
211
|
+
* @param options - Options containing the alarm ID to cancel
|
|
212
|
+
* @returns Promise resolving with the result of the action
|
|
213
|
+
* @since 8.1.0
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const result = await CapgoAlarm.cancelAlarm({ id: 'alarm-uuid-here' });
|
|
217
|
+
* if (result.success) {
|
|
218
|
+
* console.log('Alarm cancelled');
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
cancelAlarm(options: {
|
|
223
|
+
id: string;
|
|
224
|
+
}): Promise<NativeActionResult>;
|
|
205
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options for creating a native OS alarm via the platform clock app.\n *\n * @since 1.0.0\n */\nexport interface NativeAlarmCreateOptions {\n /** Hour of day in 24h format (0-23) */\n hour: number;\n /** Minute of hour (0-59) */\n minute: number;\n /** Optional label for the alarm */\n label?: string;\n /** Android only: attempt to skip UI if possible */\n skipUi?: boolean;\n /** Android only: set alarm to vibrate */\n vibrate?: boolean;\n}\n\n/**\n * Result of a native action.\n *\n * @since 1.0.0\n */\nexport interface NativeActionResult {\n /** Whether the action was successful */\n success: boolean;\n /** Optional message with additional information */\n message?: string;\n}\n\n/**\n * Information about a scheduled alarm.\n *\n * @since 1.1.0\n */\nexport interface AlarmInfo {\n /** Unique identifier for the alarm */\n id: string;\n /** Hour of day in 24h format (0-23) */\n hour
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options for creating a native OS alarm via the platform clock app.\n *\n * @since 1.0.0\n */\nexport interface NativeAlarmCreateOptions {\n /** Hour of day in 24h format (0-23) */\n hour: number;\n /** Minute of hour (0-59) */\n minute: number;\n /** Optional label for the alarm */\n label?: string;\n /** Android only: attempt to skip UI if possible */\n skipUi?: boolean;\n /** Android only: set alarm to vibrate */\n vibrate?: boolean;\n}\n\n/**\n * Result of a native action.\n *\n * @since 1.0.0\n */\nexport interface NativeActionResult {\n /** Whether the action was successful */\n success: boolean;\n /** Optional message with additional information */\n message?: string;\n /** Optional alarm ID (returned by createAlarm on iOS) */\n id?: string;\n}\n\n/**\n * Information about a scheduled alarm.\n *\n * @since 1.1.0\n */\nexport interface AlarmInfo {\n /** Unique identifier for the alarm */\n id: string;\n /** Hour of day in 24h format (0-23). May be absent for alarms created outside this plugin. */\n hour?: number;\n /** Minute of hour (0-59). May be absent for alarms created outside this plugin. */\n minute?: number;\n /** Optional label for the alarm */\n label?: string;\n /** Whether the alarm is enabled */\n enabled?: boolean;\n}\n\n/**\n * Returned info about current OS and capabilities.\n *\n * @since 1.0.0\n */\nexport interface OSInfo {\n /** Platform identifier: 'ios' | 'android' | 'web' */\n platform: string;\n /** OS version string */\n version: string;\n /** Whether the platform exposes a native alarm app integration */\n supportsNativeAlarms: boolean;\n /** Whether scheduling local notifications is supported */\n supportsScheduledNotifications: boolean;\n /** Android only: whether exact alarms are allowed */\n canScheduleExactAlarms?: boolean;\n}\n\n/**\n * Result of a permissions request.\n *\n * @since 1.0.0\n */\nexport interface PermissionResult {\n /** Overall grant for requested scope */\n granted: boolean;\n /** Optional details by permission key */\n details?: Record<string, boolean>;\n /** Optional human readable diagnostic */\n message?: string;\n}\n\n/**\n * Capacitor Alarm Plugin interface for managing native OS alarms.\n *\n * @since 1.0.0\n */\nexport interface CapgoAlarmPlugin {\n /**\n * Create a native OS alarm using the platform clock app.\n * On Android this uses the Alarm Clock intent; on iOS this uses AlarmKit if available (iOS 16+).\n *\n * @param options - Options for creating the alarm\n * @returns Promise that resolves with the action result\n * @throws Error if alarm creation fails or permissions are not granted\n * @since 1.0.0\n * @example\n * ```typescript\n * const result = await CapgoAlarm.createAlarm({\n * hour: 7,\n * minute: 30,\n * label: 'Wake up',\n * skipUi: false,\n * vibrate: true\n * });\n * console.log('Alarm created:', result.success);\n * ```\n */\n createAlarm(options: NativeAlarmCreateOptions): Promise<NativeActionResult>;\n\n /**\n * Open the platform's native alarm list UI, if available.\n *\n * @returns Promise that resolves with the action result\n * @throws Error if opening alarms UI fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const result = await CapgoAlarm.openAlarms();\n * if (result.success) {\n * console.log('Alarms UI opened');\n * }\n * ```\n */\n openAlarms(): Promise<NativeActionResult>;\n\n /**\n * Get information about the OS and capabilities.\n *\n * @returns Promise that resolves with OS information\n * @throws Error if getting OS info fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const info = await CapgoAlarm.getOSInfo();\n * console.log('Platform:', info.platform);\n * console.log('Supports native alarms:', info.supportsNativeAlarms);\n * if (info.platform === 'android') {\n * console.log('Can schedule exact alarms:', info.canScheduleExactAlarms);\n * }\n * ```\n */\n getOSInfo(): Promise<OSInfo>;\n\n /**\n * Request relevant permissions for alarm usage on the platform.\n * On Android, may route to settings for exact alarms.\n *\n * @param options - Optional parameters for the permission request\n * @returns Promise that resolves with the permission result\n * @throws Error if permission request fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const result = await CapgoAlarm.requestPermissions({ exactAlarm: true });\n * if (result.granted) {\n * console.log('Permissions granted');\n * } else {\n * console.log('Permissions denied');\n * }\n * ```\n */\n requestPermissions(options?: { exactAlarm?: boolean }): Promise<PermissionResult>;\n\n /**\n * Check the current permission state for native alarm access without triggering UI.\n * On iOS this reports AlarmKit readiness; on Android it reports capability details.\n *\n * @returns Promise that resolves with the permission result\n * @throws Error if the native layer fails to respond\n * @since 8.0.4\n * @example\n * ```typescript\n * const status = await CapgoAlarm.checkPermissions();\n * console.log('AlarmKit allowed?', status.details?.alarmKit);\n * ```\n */\n checkPermissions(): Promise<PermissionResult>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { version } = await CapgoAlarm.getPluginVersion();\n * console.log('Plugin version:', version);\n * ```\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Get a list of alarms scheduled by this app.\n * On iOS 26+, returns alarms from AlarmKit. On Android, this is not supported\n * as the system does not provide an API to query alarms.\n *\n * @returns Promise that resolves with an array of alarm information\n * @since 1.1.0\n * @example\n * ```typescript\n * const { alarms } = await CapgoAlarm.getAlarms();\n * console.log('Scheduled alarms:', alarms);\n * alarms.forEach(alarm => {\n * console.log(`Alarm ${alarm.id}: ${alarm.hour}:${alarm.minute} - ${alarm.label}`);\n * });\n * ```\n */\n getAlarms(): Promise<{ alarms: AlarmInfo[]; message?: string }>;\n\n /**\n * Cancel a scheduled alarm by its ID.\n * On iOS 26+, removes the alarm from AlarmKit. On Android/web, returns not supported.\n *\n * @param options - Options containing the alarm ID to cancel\n * @returns Promise resolving with the result of the action\n * @since 8.1.0\n * @example\n * ```typescript\n * const result = await CapgoAlarm.cancelAlarm({ id: 'alarm-uuid-here' });\n * if (result.success) {\n * console.log('Alarm cancelled');\n * }\n * ```\n */\n cancelAlarm(options: { id: string }): Promise<NativeActionResult>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,WAAW,CAAC,QAAkC;QAClD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mCAAmC,EAAE,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,SAAS,CAAC,SAAS;YAC5B,oBAAoB,EAAE,KAAK;YAC3B,8BAA8B,EAAE,KAAK;SACtC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAAmC;QAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,mDAAmD;SAC7D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CapgoAlarmPlugin,\n NativeAlarmCreateOptions,\n NativeActionResult,\n OSInfo,\n PermissionResult,\n AlarmInfo,\n} from './definitions';\n\nexport class CapgoAlarmWeb extends WebPlugin implements CapgoAlarmPlugin {\n async createAlarm(_options: NativeAlarmCreateOptions): Promise<NativeActionResult> {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n\n async openAlarms(): Promise<NativeActionResult> {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n\n async getOSInfo(): Promise<OSInfo> {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n\n async requestPermissions(_options?: { exactAlarm?: boolean }): Promise<PermissionResult> {\n return { granted: true };\n }\n\n async checkPermissions(): Promise<PermissionResult> {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async getAlarms(): Promise<{ alarms: AlarmInfo[] }> {\n return { alarms: [] };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,WAAW,CAAC,QAAkC;QAClD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mCAAmC,EAAE,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,SAAS,CAAC,SAAS;YAC5B,oBAAoB,EAAE,KAAK;YAC3B,8BAA8B,EAAE,KAAK;SACtC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAAmC;QAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,mDAAmD;SAC7D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAwB;QACxC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CapgoAlarmPlugin,\n NativeAlarmCreateOptions,\n NativeActionResult,\n OSInfo,\n PermissionResult,\n AlarmInfo,\n} from './definitions';\n\nexport class CapgoAlarmWeb extends WebPlugin implements CapgoAlarmPlugin {\n async createAlarm(_options: NativeAlarmCreateOptions): Promise<NativeActionResult> {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n\n async openAlarms(): Promise<NativeActionResult> {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n\n async getOSInfo(): Promise<OSInfo> {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n\n async requestPermissions(_options?: { exactAlarm?: boolean }): Promise<PermissionResult> {\n return { granted: true };\n }\n\n async checkPermissions(): Promise<PermissionResult> {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async getAlarms(): Promise<{ alarms: AlarmInfo[] }> {\n return { alarms: [] };\n }\n\n async cancelAlarm(_options: { id: string }): Promise<NativeActionResult> {\n return { success: false, message: 'Cancel alarm is not supported on web' };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -67,6 +67,9 @@ class CapgoAlarmWeb extends core.WebPlugin {
|
|
|
67
67
|
async getAlarms() {
|
|
68
68
|
return { alarms: [] };
|
|
69
69
|
}
|
|
70
|
+
async cancelAlarm(_options) {
|
|
71
|
+
return { success: false, message: 'Cancel alarm is not supported on web' };
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["var _a;\nimport { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\n});\nconst missingCheckPermissionsResult = {\n granted: false,\n message: 'CapgoAlarm.checkPermissions is not implemented on this platform or native plugin version. Update the native plugin to use this feature.',\n};\nconst nativeCheckPermissions = (_a = CapgoAlarm.checkPermissions) === null || _a === void 0 ? void 0 : _a.bind(CapgoAlarm);\nCapgoAlarm.checkPermissions = (async () => {\n if (!nativeCheckPermissions) {\n return missingCheckPermissionsResult;\n }\n try {\n return await nativeCheckPermissions();\n }\n catch (error) {\n if (isUnimplementedError(error)) {\n return missingCheckPermissionsResult;\n }\n throw error;\n }\n});\nfunction isUnimplementedError(error) {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = error.code;\n if (code === 'UNIMPLEMENTED') {\n return true;\n }\n const message = error.message;\n return typeof message === 'string' && message.toLowerCase().includes('not implemented');\n}\nexport * from './definitions';\nexport { CapgoAlarm };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapgoAlarmWeb extends WebPlugin {\n async createAlarm(_options) {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n async openAlarms() {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n async getOSInfo() {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n async requestPermissions(_options) {\n return { granted: true };\n }\n async checkPermissions() {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA,IAAI,EAAE;AAED,MAAC,UAAU,GAAGA,mBAAc,CAAC,YA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IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mCAAmC,EAAE;AAC/E,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE;AAClF,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,OAAO,EAAE,SAAS,CAAC,SAAS;AACxC,YAAY,oBAAoB,EAAE,KAAK;AACvC,YAAY,8BAA8B,EAAE,KAAK;AACjD,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,KAAK;AAC1B,YAAY,OAAO,EAAE,mDAAmD;AACxE,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;AAC7B,IAAI;AACJ;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["var _a;\nimport { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\n});\nconst missingCheckPermissionsResult = {\n granted: false,\n message: 'CapgoAlarm.checkPermissions is not implemented on this platform or native plugin version. Update the native plugin to use this feature.',\n};\nconst nativeCheckPermissions = (_a = CapgoAlarm.checkPermissions) === null || _a === void 0 ? void 0 : _a.bind(CapgoAlarm);\nCapgoAlarm.checkPermissions = (async () => {\n if (!nativeCheckPermissions) {\n return missingCheckPermissionsResult;\n }\n try {\n return await nativeCheckPermissions();\n }\n catch (error) {\n if (isUnimplementedError(error)) {\n return missingCheckPermissionsResult;\n }\n throw error;\n }\n});\nfunction isUnimplementedError(error) {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = error.code;\n if (code === 'UNIMPLEMENTED') {\n return true;\n }\n const message = error.message;\n return typeof message === 'string' && message.toLowerCase().includes('not implemented');\n}\nexport * from './definitions';\nexport { CapgoAlarm };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapgoAlarmWeb extends WebPlugin {\n async createAlarm(_options) {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n async openAlarms() {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n async getOSInfo() {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n async requestPermissions(_options) {\n return { granted: true };\n }\n async checkPermissions() {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n async cancelAlarm(_options) {\n return { success: false, message: 'Cancel alarm is not supported on web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA,IAAI,EAAE;AAED,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AACjE,CAAC;AACD,MAAM,6BAA6B,GAAG;AACtC,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,OAAO,EAAE,yIAAyI;AACtJ,CAAC;AACD,MAAM,sBAAsB,GAAG,CAAC,EAAE,GAAG,UA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B,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,OAAO,EAAE,SAAS,CAAC,SAAS;AACxC,YAAY,oBAAoB,EAAE,KAAK;AACvC,YAAY,8BAA8B,EAAE,KAAK;AACjD,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,KAAK;AAC1B,YAAY,OAAO,EAAE,mDAAmD;AACxE,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;AAC7B,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE;AAClF,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -66,6 +66,9 @@ var capacitorCapgoAlarm = (function (exports, core) {
|
|
|
66
66
|
async getAlarms() {
|
|
67
67
|
return { alarms: [] };
|
|
68
68
|
}
|
|
69
|
+
async cancelAlarm(_options) {
|
|
70
|
+
return { success: false, message: 'Cancel alarm is not supported on web' };
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["var _a;\nimport { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\n});\nconst missingCheckPermissionsResult = {\n granted: false,\n message: 'CapgoAlarm.checkPermissions is not implemented on this platform or native plugin version. Update the native plugin to use this feature.',\n};\nconst nativeCheckPermissions = (_a = CapgoAlarm.checkPermissions) === null || _a === void 0 ? void 0 : _a.bind(CapgoAlarm);\nCapgoAlarm.checkPermissions = (async () => {\n if (!nativeCheckPermissions) {\n return missingCheckPermissionsResult;\n }\n try {\n return await nativeCheckPermissions();\n }\n catch (error) {\n if (isUnimplementedError(error)) {\n return missingCheckPermissionsResult;\n }\n throw error;\n }\n});\nfunction isUnimplementedError(error) {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = error.code;\n if (code === 'UNIMPLEMENTED') {\n return true;\n }\n const message = error.message;\n return typeof message === 'string' && message.toLowerCase().includes('not implemented');\n}\nexport * from './definitions';\nexport { CapgoAlarm };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapgoAlarmWeb extends WebPlugin {\n async createAlarm(_options) {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n async openAlarms() {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n async getOSInfo() {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n async requestPermissions(_options) {\n return { granted: true };\n }\n async checkPermissions() {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA,IAAI,EAAE;AAED,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,6BAA6B,GA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AG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE;IAClF,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO;IACf,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,OAAO,EAAE,SAAS,CAAC,SAAS;IACxC,YAAY,oBAAoB,EAAE,KAAK;IACvC,YAAY,8BAA8B,EAAE,KAAK;IACjD,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;IAChC,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO;IACf,YAAY,OAAO,EAAE,KAAK;IAC1B,YAAY,OAAO,EAAE,mDAAmD;IACxE,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7B,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["var _a;\nimport { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\n});\nconst missingCheckPermissionsResult = {\n granted: false,\n message: 'CapgoAlarm.checkPermissions is not implemented on this platform or native plugin version. Update the native plugin to use this feature.',\n};\nconst nativeCheckPermissions = (_a = CapgoAlarm.checkPermissions) === null || _a === void 0 ? void 0 : _a.bind(CapgoAlarm);\nCapgoAlarm.checkPermissions = (async () => {\n if (!nativeCheckPermissions) {\n return missingCheckPermissionsResult;\n }\n try {\n return await nativeCheckPermissions();\n }\n catch (error) {\n if (isUnimplementedError(error)) {\n return missingCheckPermissionsResult;\n }\n throw error;\n }\n});\nfunction isUnimplementedError(error) {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = error.code;\n if (code === 'UNIMPLEMENTED') {\n return true;\n }\n const message = error.message;\n return typeof message === 'string' && message.toLowerCase().includes('not implemented');\n}\nexport * from './definitions';\nexport { CapgoAlarm };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapgoAlarmWeb extends WebPlugin {\n async createAlarm(_options) {\n return { success: false, message: 'Native alarm not supported on web' };\n }\n async openAlarms() {\n return { success: false, message: 'Native alarm UI not available on web' };\n }\n async getOSInfo() {\n return {\n platform: 'web',\n version: navigator.userAgent,\n supportsNativeAlarms: false,\n supportsScheduledNotifications: false,\n };\n }\n async requestPermissions(_options) {\n return { granted: true };\n }\n async checkPermissions() {\n return {\n granted: false,\n message: 'Native alarm permissions are not available on web',\n };\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n async cancelAlarm(_options) {\n return { success: false, message: 'Cancel alarm is not supported on web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA,IAAI,EAAE;AAED,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,6BAA6B,GAAG;IACtC,IAAI,OAAO,EAAE,KAAK;IAClB,IAAI,OAAO,EAAE,yIAAyI;IACtJ,CAAC;IACD,MAAM,sBAAsB,GAAG,CAAC,EAAE,GAAG,UAAU,CAAC,gBAAgB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;IAC1H,UAAU,CAAC,gBAAgB,IAAI,YAAY;IAC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K;IACjD,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;IAChC,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO;IACf,YAAY,OAAO,EAAE,KAAK;IAC1B,YAAY,OAAO,EAAE,mDAAmD;IACxE,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7B,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE;IAClF,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -16,6 +16,71 @@ private struct AlarmBridgeMetadata: AlarmMetadata {
|
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
class AlarmKitBridge {
|
|
19
|
+
// MARK: - UserDefaults Storage for Alarm Metadata
|
|
20
|
+
|
|
21
|
+
private static let storageKey = "CapgoAlarm.alarmMetadata"
|
|
22
|
+
private static let metadataQueue = DispatchQueue(label: "CapgoAlarm.alarmMetadata.queue")
|
|
23
|
+
|
|
24
|
+
private static func loadStoredMetadata() -> [String: [String: Any]] {
|
|
25
|
+
UserDefaults.standard.dictionary(forKey: storageKey) as? [String: [String: Any]] ?? [:]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static func saveStoredMetadata(_ metadata: [String: [String: Any]]) {
|
|
29
|
+
UserDefaults.standard.set(metadata, forKey: storageKey)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private static func storeAlarmMetadata(id: String, hour: Int, minute: Int, label: String?) {
|
|
33
|
+
metadataQueue.sync {
|
|
34
|
+
var metadata = loadStoredMetadata()
|
|
35
|
+
var entry: [String: Any] = [
|
|
36
|
+
"hour": hour,
|
|
37
|
+
"minute": minute
|
|
38
|
+
]
|
|
39
|
+
if let label = label {
|
|
40
|
+
entry["label"] = label
|
|
41
|
+
}
|
|
42
|
+
metadata[id] = entry
|
|
43
|
+
saveStoredMetadata(metadata)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private static func removeAlarmMetadata(id: String) {
|
|
48
|
+
metadataQueue.sync {
|
|
49
|
+
var metadata = loadStoredMetadata()
|
|
50
|
+
metadata.removeValue(forKey: id)
|
|
51
|
+
saveStoredMetadata(metadata)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private static func getAlarmMetadata(id: String) -> (hour: Int, minute: Int, label: String?)? {
|
|
56
|
+
metadataQueue.sync {
|
|
57
|
+
let metadata = loadStoredMetadata()
|
|
58
|
+
guard let data = metadata[id],
|
|
59
|
+
let hour = data["hour"] as? Int,
|
|
60
|
+
let minute = data["minute"] as? Int else {
|
|
61
|
+
return nil
|
|
62
|
+
}
|
|
63
|
+
let label = data["label"] as? String
|
|
64
|
+
return (hour, minute, label)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private static func pruneOrphanedMetadata(validIds: Set<String>) {
|
|
69
|
+
metadataQueue.sync {
|
|
70
|
+
var metadata = loadStoredMetadata()
|
|
71
|
+
let storedIds = Set(metadata.keys)
|
|
72
|
+
let orphanedIds = storedIds.subtracting(validIds)
|
|
73
|
+
for id in orphanedIds {
|
|
74
|
+
metadata.removeValue(forKey: id)
|
|
75
|
+
}
|
|
76
|
+
if !orphanedIds.isEmpty {
|
|
77
|
+
saveStoredMetadata(metadata)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// MARK: - Public API
|
|
83
|
+
|
|
19
84
|
static func isAvailable() -> Bool {
|
|
20
85
|
#if canImport(AlarmKit)
|
|
21
86
|
if #available(iOS 26.0, *) { return true } else { return false }
|
|
@@ -53,24 +118,29 @@ class AlarmKitBridge {
|
|
|
53
118
|
completion(false, "AlarmKit not available on this device/SDK")
|
|
54
119
|
}
|
|
55
120
|
|
|
56
|
-
static func createAlarm(hour: Int, minute: Int, label: String?, completion: @escaping (Bool, String?) -> Void) {
|
|
121
|
+
static func createAlarm(hour: Int, minute: Int, label: String?, completion: @escaping (Bool, String?, String?) -> Void) {
|
|
57
122
|
#if canImport(AlarmKit)
|
|
58
123
|
if #available(iOS 26.0, *) {
|
|
59
124
|
guard (0..<24).contains(hour), (0..<60).contains(minute) else {
|
|
60
|
-
completion(false, "Invalid time components for alarm.")
|
|
125
|
+
completion(false, "Invalid time components for alarm.", nil)
|
|
61
126
|
return
|
|
62
127
|
}
|
|
63
128
|
|
|
64
129
|
Task {
|
|
65
130
|
do {
|
|
66
131
|
guard let triggerDate = nextTriggerDate(hour: hour, minute: minute) else {
|
|
67
|
-
completion(false, "Unable to compute next trigger date.")
|
|
132
|
+
completion(false, "Unable to compute next trigger date.", nil)
|
|
68
133
|
return
|
|
69
134
|
}
|
|
70
135
|
let displayLabel = sanitizedLabel(label)
|
|
71
136
|
let configuration = try alarmConfiguration(triggerDate: triggerDate, label: displayLabel)
|
|
72
137
|
|
|
73
|
-
|
|
138
|
+
// Generate UUID upfront so we can return it and store metadata
|
|
139
|
+
let alarmId = UUID()
|
|
140
|
+
_ = try await AlarmManager.shared.schedule(id: alarmId, configuration: configuration)
|
|
141
|
+
|
|
142
|
+
// Store metadata for later retrieval (use displayLabel so stored title matches system)
|
|
143
|
+
storeAlarmMetadata(id: alarmId.uuidString, hour: hour, minute: minute, label: displayLabel)
|
|
74
144
|
|
|
75
145
|
let formatter = DateFormatter()
|
|
76
146
|
formatter.dateStyle = .none
|
|
@@ -79,15 +149,15 @@ class AlarmKitBridge {
|
|
|
79
149
|
formatter.timeZone = Calendar.current.timeZone
|
|
80
150
|
|
|
81
151
|
let message = "Alarm scheduled for \(formatter.string(from: triggerDate))."
|
|
82
|
-
completion(true, message)
|
|
152
|
+
completion(true, message, alarmId.uuidString)
|
|
83
153
|
} catch {
|
|
84
|
-
completion(false, "Failed to schedule alarm: \(error.localizedDescription)")
|
|
154
|
+
completion(false, "Failed to schedule alarm: \(error.localizedDescription)", nil)
|
|
85
155
|
}
|
|
86
156
|
}
|
|
87
157
|
return
|
|
88
158
|
}
|
|
89
159
|
#endif
|
|
90
|
-
completion(false, "AlarmKit not available on this device/SDK")
|
|
160
|
+
completion(false, "AlarmKit not available on this device/SDK", nil)
|
|
91
161
|
}
|
|
92
162
|
|
|
93
163
|
static func openAlarms(completion: @escaping (Bool, String?) -> Void) {
|
|
@@ -109,6 +179,10 @@ class AlarmKitBridge {
|
|
|
109
179
|
let alarmManager = AlarmManager.shared
|
|
110
180
|
let alarms = try alarmManager.alarms
|
|
111
181
|
|
|
182
|
+
// Collect valid alarm IDs and prune orphaned metadata
|
|
183
|
+
let validIds = Set(alarms.map { $0.id.uuidString })
|
|
184
|
+
pruneOrphanedMetadata(validIds: validIds)
|
|
185
|
+
|
|
112
186
|
var alarmsList: [[String: Any]] = []
|
|
113
187
|
for alarm in alarms {
|
|
114
188
|
if let alarmDict = convertAlarmToDict(alarm: alarm) {
|
|
@@ -127,46 +201,52 @@ class AlarmKitBridge {
|
|
|
127
201
|
// Return empty list for consistency with Android/Web when not supported
|
|
128
202
|
completion([], nil)
|
|
129
203
|
}
|
|
204
|
+
|
|
205
|
+
static func cancelAlarm(id: String, completion: @escaping (Bool, String?) -> Void) {
|
|
206
|
+
#if canImport(AlarmKit)
|
|
207
|
+
if #available(iOS 26.0, *) {
|
|
208
|
+
guard let uuid = UUID(uuidString: id) else {
|
|
209
|
+
completion(false, "Invalid alarm ID format")
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
do {
|
|
213
|
+
try AlarmManager.shared.cancel(id: uuid)
|
|
214
|
+
// Clean up stored metadata
|
|
215
|
+
removeAlarmMetadata(id: id)
|
|
216
|
+
completion(true, "Alarm cancelled")
|
|
217
|
+
} catch {
|
|
218
|
+
completion(false, "Failed to cancel alarm: \(error.localizedDescription)")
|
|
219
|
+
}
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
#endif
|
|
223
|
+
completion(false, "AlarmKit not available on this device/SDK")
|
|
224
|
+
}
|
|
130
225
|
}
|
|
131
226
|
|
|
132
227
|
#if canImport(AlarmKit)
|
|
133
228
|
@available(iOS 26.0, *)
|
|
134
229
|
private extension AlarmKitBridge {
|
|
135
230
|
static func convertAlarmToDict(alarm: Alarm) -> [String: Any]? {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let schedule = alarm.configuration.schedule
|
|
139
|
-
|
|
140
|
-
// Extract date based on schedule type
|
|
141
|
-
if case .fixed(let date) = schedule {
|
|
142
|
-
triggerDate = date
|
|
143
|
-
} else if case .repeating(let dateComponents) = schedule {
|
|
144
|
-
// For repeating alarms, create a date from components
|
|
145
|
-
triggerDate = Calendar.current.date(from: dateComponents)
|
|
146
|
-
}
|
|
231
|
+
let idString = alarm.id.uuidString
|
|
232
|
+
let isEnabled = alarm.state == .scheduled || alarm.state == .countdown || alarm.state == .alerting
|
|
147
233
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let components = Calendar.current.dateComponents([.hour, .minute], from: date)
|
|
153
|
-
guard let hour = components.hour, let minute = components.minute else {
|
|
154
|
-
return nil
|
|
155
|
-
}
|
|
234
|
+
var dict: [String: Any] = [
|
|
235
|
+
"id": idString,
|
|
236
|
+
"enabled": isEnabled
|
|
237
|
+
]
|
|
156
238
|
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
239
|
+
// Look up stored metadata for hour/minute/label
|
|
240
|
+
if let metadata = getAlarmMetadata(id: idString) {
|
|
241
|
+
dict["hour"] = metadata.hour
|
|
242
|
+
dict["minute"] = metadata.minute
|
|
243
|
+
if let label = metadata.label {
|
|
244
|
+
dict["label"] = label
|
|
245
|
+
}
|
|
161
246
|
}
|
|
247
|
+
// If no stored metadata (alarm created outside this plugin), hour/minute/label are omitted
|
|
162
248
|
|
|
163
|
-
return
|
|
164
|
-
"id": alarm.id.uuidString,
|
|
165
|
-
"hour": hour,
|
|
166
|
-
"minute": minute,
|
|
167
|
-
"label": label ?? NSNull(),
|
|
168
|
-
"enabled": alarm.state == .active
|
|
169
|
-
]
|
|
249
|
+
return dict
|
|
170
250
|
}
|
|
171
251
|
|
|
172
252
|
static func sanitizedLabel(_ label: String?) -> String {
|
|
@@ -7,7 +7,7 @@ import Capacitor
|
|
|
7
7
|
*/
|
|
8
8
|
@objc(CapgoAlarmPlugin)
|
|
9
9
|
public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.0
|
|
10
|
+
private let pluginVersion: String = "8.1.0"
|
|
11
11
|
public let identifier = "CapgoAlarmPlugin"
|
|
12
12
|
public let jsName = "CapgoAlarm"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -17,7 +17,8 @@ public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
17
17
|
CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
|
|
18
18
|
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
|
|
19
19
|
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
20
|
-
CAPPluginMethod(name: "getAlarms", returnType: CAPPluginReturnPromise)
|
|
20
|
+
CAPPluginMethod(name: "getAlarms", returnType: CAPPluginReturnPromise),
|
|
21
|
+
CAPPluginMethod(name: "cancelAlarm", returnType: CAPPluginReturnPromise)
|
|
21
22
|
]
|
|
22
23
|
|
|
23
24
|
@objc func createAlarm(_ call: CAPPluginCall) {
|
|
@@ -26,8 +27,12 @@ public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
26
27
|
if hour < 0 || minute < 0 { call.reject("hour and minute are required"); return }
|
|
27
28
|
let label = call.getString("label")
|
|
28
29
|
|
|
29
|
-
AlarmKitBridge.createAlarm(hour: hour, minute: minute, label: label) { success, message in
|
|
30
|
-
|
|
30
|
+
AlarmKitBridge.createAlarm(hour: hour, minute: minute, label: label) { success, message, alarmId in
|
|
31
|
+
var result: [String: Any] = ["success": success, "message": message ?? NSNull()]
|
|
32
|
+
if let alarmId = alarmId {
|
|
33
|
+
result["id"] = alarmId
|
|
34
|
+
}
|
|
35
|
+
call.resolve(result)
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -101,4 +106,14 @@ public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
@objc func cancelAlarm(_ call: CAPPluginCall) {
|
|
110
|
+
guard let id = call.getString("id") else {
|
|
111
|
+
call.reject("Missing alarm id")
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
AlarmKitBridge.cancelAlarm(id: id) { success, message in
|
|
115
|
+
call.resolve(["success": success, "message": message ?? NSNull()])
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
104
119
|
}
|