@capgo/capacitor-alarm 8.0.5 → 8.0.6
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 +31 -0
- package/android/src/main/java/app/capgo/capacitor/alarm/CapgoAlarmPlugin.java +10 -1
- package/dist/docs.json +74 -0
- package/dist/esm/definitions.d.ts +37 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -1
- 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 +64 -0
- package/ios/Sources/CapgoAlarmPlugin/CapgoAlarmPlugin.swift +14 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ Note: This plugin only exposes native alarm actions (create/open). It does not i
|
|
|
46
46
|
* [`getOSInfo()`](#getosinfo)
|
|
47
47
|
* [`requestPermissions(...)`](#requestpermissions)
|
|
48
48
|
* [`getPluginVersion()`](#getpluginversion)
|
|
49
|
+
* [`getAlarms()`](#getalarms)
|
|
49
50
|
* [Interfaces](#interfaces)
|
|
50
51
|
* [Type Aliases](#type-aliases)
|
|
51
52
|
|
|
@@ -141,6 +142,23 @@ Get the native Capacitor plugin version.
|
|
|
141
142
|
--------------------
|
|
142
143
|
|
|
143
144
|
|
|
145
|
+
### getAlarms()
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
getAlarms() => Promise<{ alarms: AlarmInfo[]; message?: string; }>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Get a list of alarms scheduled by this app.
|
|
152
|
+
On iOS 26+, returns alarms from AlarmKit. On Android, this is not supported
|
|
153
|
+
as the system does not provide an API to query alarms.
|
|
154
|
+
|
|
155
|
+
**Returns:** <code>Promise<{ alarms: AlarmInfo[]; message?: string; }></code>
|
|
156
|
+
|
|
157
|
+
**Since:** 1.1.0
|
|
158
|
+
|
|
159
|
+
--------------------
|
|
160
|
+
|
|
161
|
+
|
|
144
162
|
### Interfaces
|
|
145
163
|
|
|
146
164
|
|
|
@@ -190,6 +208,19 @@ Result of a permissions request.
|
|
|
190
208
|
| **`details`** | <code><a href="#record">Record</a><string, boolean></code> | Optional details by permission key |
|
|
191
209
|
|
|
192
210
|
|
|
211
|
+
#### AlarmInfo
|
|
212
|
+
|
|
213
|
+
Information about a scheduled alarm.
|
|
214
|
+
|
|
215
|
+
| Prop | Type | Description |
|
|
216
|
+
| ------------- | -------------------- | -------------------------------- |
|
|
217
|
+
| **`id`** | <code>string</code> | Unique identifier for the alarm |
|
|
218
|
+
| **`hour`** | <code>number</code> | Hour of day in 24h format (0-23) |
|
|
219
|
+
| **`minute`** | <code>number</code> | Minute of hour (0-59) |
|
|
220
|
+
| **`label`** | <code>string</code> | Optional label for the alarm |
|
|
221
|
+
| **`enabled`** | <code>boolean</code> | Whether the alarm is enabled |
|
|
222
|
+
|
|
223
|
+
|
|
193
224
|
### Type Aliases
|
|
194
225
|
|
|
195
226
|
|
|
@@ -14,7 +14,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
14
14
|
@CapacitorPlugin(name = "CapgoAlarm")
|
|
15
15
|
public class CapgoAlarmPlugin extends Plugin {
|
|
16
16
|
|
|
17
|
-
private final String pluginVersion = "8.0.
|
|
17
|
+
private final String pluginVersion = "8.0.6";
|
|
18
18
|
|
|
19
19
|
// ===== Native OS Alarm helpers (Android) =====
|
|
20
20
|
@PluginMethod
|
|
@@ -117,4 +117,13 @@ public class CapgoAlarmPlugin extends Plugin {
|
|
|
117
117
|
call.reject("Could not get plugin version", e);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
@PluginMethod
|
|
122
|
+
public void getAlarms(PluginCall call) {
|
|
123
|
+
// Android does not provide a public API to query system alarms
|
|
124
|
+
// Each app must track its own alarms
|
|
125
|
+
JSObject ret = new JSObject();
|
|
126
|
+
ret.put("alarms", new org.json.JSONArray());
|
|
127
|
+
call.resolve(ret);
|
|
128
|
+
}
|
|
120
129
|
}
|
package/dist/docs.json
CHANGED
|
@@ -173,6 +173,31 @@
|
|
|
173
173
|
"docs": "Get the native Capacitor plugin version.",
|
|
174
174
|
"complexTypes": [],
|
|
175
175
|
"slug": "getpluginversion"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "getAlarms",
|
|
179
|
+
"signature": "() => Promise<{ alarms: AlarmInfo[]; message?: string; }>",
|
|
180
|
+
"parameters": [],
|
|
181
|
+
"returns": "Promise<{ alarms: AlarmInfo[]; message?: string | undefined; }>",
|
|
182
|
+
"tags": [
|
|
183
|
+
{
|
|
184
|
+
"name": "returns",
|
|
185
|
+
"text": "Promise that resolves with an array of alarm information"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "since",
|
|
189
|
+
"text": "1.1.0"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "example",
|
|
193
|
+
"text": "```typescript\nconst { alarms } = await CapgoAlarm.getAlarms();\nconsole.log('Scheduled alarms:', alarms);\nalarms.forEach(alarm => {\n console.log(`Alarm ${alarm.id}: ${alarm.hour}:${alarm.minute} - ${alarm.label}`);\n});\n```"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"docs": "Get a list of alarms scheduled by this app.\nOn iOS 26+, returns alarms from AlarmKit. On Android, this is not supported\nas the system does not provide an API to query alarms.",
|
|
197
|
+
"complexTypes": [
|
|
198
|
+
"AlarmInfo"
|
|
199
|
+
],
|
|
200
|
+
"slug": "getalarms"
|
|
176
201
|
}
|
|
177
202
|
],
|
|
178
203
|
"properties": []
|
|
@@ -333,6 +358,55 @@
|
|
|
333
358
|
"type": "Record<string, boolean>"
|
|
334
359
|
}
|
|
335
360
|
]
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"name": "AlarmInfo",
|
|
364
|
+
"slug": "alarminfo",
|
|
365
|
+
"docs": "Information about a scheduled alarm.",
|
|
366
|
+
"tags": [
|
|
367
|
+
{
|
|
368
|
+
"text": "1.1.0",
|
|
369
|
+
"name": "since"
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"methods": [],
|
|
373
|
+
"properties": [
|
|
374
|
+
{
|
|
375
|
+
"name": "id",
|
|
376
|
+
"tags": [],
|
|
377
|
+
"docs": "Unique identifier for the alarm",
|
|
378
|
+
"complexTypes": [],
|
|
379
|
+
"type": "string"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "hour",
|
|
383
|
+
"tags": [],
|
|
384
|
+
"docs": "Hour of day in 24h format (0-23)",
|
|
385
|
+
"complexTypes": [],
|
|
386
|
+
"type": "number"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "minute",
|
|
390
|
+
"tags": [],
|
|
391
|
+
"docs": "Minute of hour (0-59)",
|
|
392
|
+
"complexTypes": [],
|
|
393
|
+
"type": "number"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"name": "label",
|
|
397
|
+
"tags": [],
|
|
398
|
+
"docs": "Optional label for the alarm",
|
|
399
|
+
"complexTypes": [],
|
|
400
|
+
"type": "string | undefined"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "enabled",
|
|
404
|
+
"tags": [],
|
|
405
|
+
"docs": "Whether the alarm is enabled",
|
|
406
|
+
"complexTypes": [],
|
|
407
|
+
"type": "boolean | undefined"
|
|
408
|
+
}
|
|
409
|
+
]
|
|
336
410
|
}
|
|
337
411
|
],
|
|
338
412
|
"enums": [],
|
|
@@ -26,6 +26,23 @@ export interface NativeActionResult {
|
|
|
26
26
|
/** Optional message with additional information */
|
|
27
27
|
message?: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Information about a scheduled alarm.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.1.0
|
|
33
|
+
*/
|
|
34
|
+
export interface AlarmInfo {
|
|
35
|
+
/** Unique identifier for the alarm */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Hour of day in 24h format (0-23) */
|
|
38
|
+
hour: number;
|
|
39
|
+
/** Minute of hour (0-59) */
|
|
40
|
+
minute: number;
|
|
41
|
+
/** Optional label for the alarm */
|
|
42
|
+
label?: string;
|
|
43
|
+
/** Whether the alarm is enabled */
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
}
|
|
29
46
|
/**
|
|
30
47
|
* Returned info about current OS and capabilities.
|
|
31
48
|
*
|
|
@@ -149,4 +166,24 @@ export interface CapgoAlarmPlugin {
|
|
|
149
166
|
getPluginVersion(): Promise<{
|
|
150
167
|
version: string;
|
|
151
168
|
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Get a list of alarms scheduled by this app.
|
|
171
|
+
* On iOS 26+, returns alarms from AlarmKit. On Android, this is not supported
|
|
172
|
+
* as the system does not provide an API to query alarms.
|
|
173
|
+
*
|
|
174
|
+
* @returns Promise that resolves with an array of alarm information
|
|
175
|
+
* @since 1.1.0
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const { alarms } = await CapgoAlarm.getAlarms();
|
|
179
|
+
* console.log('Scheduled alarms:', alarms);
|
|
180
|
+
* alarms.forEach(alarm => {
|
|
181
|
+
* console.log(`Alarm ${alarm.id}: ${alarm.hour}:${alarm.minute} - ${alarm.label}`);
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
getAlarms(): Promise<{
|
|
186
|
+
alarms: AlarmInfo[];
|
|
187
|
+
message?: string;
|
|
188
|
+
}>;
|
|
152
189
|
}
|
|
@@ -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 * 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}\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 * 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"]}
|
|
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: number;\n /** Minute of hour (0-59) */\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}\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 * 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"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { CapgoAlarmPlugin, NativeAlarmCreateOptions, NativeActionResult, OSInfo, PermissionResult } from './definitions';
|
|
2
|
+
import type { CapgoAlarmPlugin, NativeAlarmCreateOptions, NativeActionResult, OSInfo, PermissionResult, AlarmInfo } from './definitions';
|
|
3
3
|
export declare class CapgoAlarmWeb extends WebPlugin implements CapgoAlarmPlugin {
|
|
4
4
|
createAlarm(_options: NativeAlarmCreateOptions): Promise<NativeActionResult>;
|
|
5
5
|
openAlarms(): Promise<NativeActionResult>;
|
|
@@ -10,4 +10,7 @@ export declare class CapgoAlarmWeb extends WebPlugin implements CapgoAlarmPlugin
|
|
|
10
10
|
getPluginVersion(): Promise<{
|
|
11
11
|
version: string;
|
|
12
12
|
}>;
|
|
13
|
+
getAlarms(): Promise<{
|
|
14
|
+
alarms: AlarmInfo[];
|
|
15
|
+
}>;
|
|
13
16
|
}
|
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;
|
|
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,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 getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async getAlarms(): Promise<{ alarms: AlarmInfo[] }> {\n return { alarms: [] };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\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 getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,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;;ACFM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,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,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\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 getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,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;;ACFM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,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,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;AAC7B,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\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 getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,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;;ICFM,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mCAAmC,EAAE;IAC/E,IAAI;IACJ,IAAI,MAAM,UAAU,GAAG;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,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapgoAlarm = registerPlugin('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\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 getPluginVersion() {\n return { version: 'web' };\n }\n async getAlarms() {\n return { alarms: [] };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,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;;ICFM,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mCAAmC,EAAE;IAC/E,IAAI;IACJ,IAAI,MAAM,UAAU,GAAG;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,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7B,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -89,11 +89,75 @@ class AlarmKitBridge {
|
|
|
89
89
|
completion(false, "Clock UI cannot be opened on this platform.")
|
|
90
90
|
#endif
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
static func getAlarms(completion: @escaping ([[String: Any]], String?) -> Void) {
|
|
94
|
+
#if canImport(AlarmKit)
|
|
95
|
+
if #available(iOS 26.0, *) {
|
|
96
|
+
Task {
|
|
97
|
+
do {
|
|
98
|
+
let alarmManager = AlarmManager.shared
|
|
99
|
+
let alarms = try alarmManager.alarms
|
|
100
|
+
|
|
101
|
+
var alarmsList: [[String: Any]] = []
|
|
102
|
+
for alarm in alarms {
|
|
103
|
+
if let alarmDict = convertAlarmToDict(alarm: alarm) {
|
|
104
|
+
alarmsList.append(alarmDict)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
completion(alarmsList, nil)
|
|
109
|
+
} catch {
|
|
110
|
+
completion([], "Failed to retrieve alarms: \(error.localizedDescription)")
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
#endif
|
|
116
|
+
// Return empty list for consistency with Android/Web when not supported
|
|
117
|
+
completion([], nil)
|
|
118
|
+
}
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
#if canImport(AlarmKit)
|
|
95
122
|
@available(iOS 26.0, *)
|
|
96
123
|
private extension AlarmKitBridge {
|
|
124
|
+
static func convertAlarmToDict(alarm: Alarm) -> [String: Any]? {
|
|
125
|
+
// Get the trigger date from the schedule
|
|
126
|
+
var triggerDate: Date?
|
|
127
|
+
let schedule = alarm.configuration.schedule
|
|
128
|
+
|
|
129
|
+
// Extract date based on schedule type
|
|
130
|
+
if case .fixed(let date) = schedule {
|
|
131
|
+
triggerDate = date
|
|
132
|
+
} else if case .repeating(let dateComponents) = schedule {
|
|
133
|
+
// For repeating alarms, create a date from components
|
|
134
|
+
triggerDate = Calendar.current.date(from: dateComponents)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
guard let date = triggerDate else {
|
|
138
|
+
return nil
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let components = Calendar.current.dateComponents([.hour, .minute], from: date)
|
|
142
|
+
guard let hour = components.hour, let minute = components.minute else {
|
|
143
|
+
return nil
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Try to get label from metadata if available
|
|
147
|
+
var label: String? = nil
|
|
148
|
+
if let metadata = alarm.configuration.attributes.metadata as? AlarmBridgeMetadata {
|
|
149
|
+
label = metadata.label
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return [
|
|
153
|
+
"id": alarm.id.uuidString,
|
|
154
|
+
"hour": hour,
|
|
155
|
+
"minute": minute,
|
|
156
|
+
"label": label ?? NSNull(),
|
|
157
|
+
"enabled": alarm.state == .active
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
|
|
97
161
|
static func sanitizedLabel(_ label: String?) -> String {
|
|
98
162
|
let trimmed = label?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
99
163
|
return trimmed.isEmpty ? "Alarm" : trimmed
|
|
@@ -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.0.6"
|
|
11
11
|
public let identifier = "CapgoAlarmPlugin"
|
|
12
12
|
public let jsName = "CapgoAlarm"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -15,7 +15,8 @@ public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
15
15
|
CAPPluginMethod(name: "openAlarms", returnType: CAPPluginReturnPromise),
|
|
16
16
|
CAPPluginMethod(name: "getOSInfo", returnType: CAPPluginReturnPromise),
|
|
17
17
|
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
|
|
18
|
-
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
18
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "getAlarms", returnType: CAPPluginReturnPromise)
|
|
19
20
|
]
|
|
20
21
|
|
|
21
22
|
@objc func createAlarm(_ call: CAPPluginCall) {
|
|
@@ -71,4 +72,15 @@ public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
71
72
|
call.resolve(["version": self.pluginVersion])
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
@objc func getAlarms(_ call: CAPPluginCall) {
|
|
76
|
+
AlarmKitBridge.getAlarms { alarms, error in
|
|
77
|
+
if let error = error {
|
|
78
|
+
// Return empty array with error message for consistency
|
|
79
|
+
call.resolve(["alarms": [], "message": error])
|
|
80
|
+
} else {
|
|
81
|
+
call.resolve(["alarms": alarms])
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
}
|