@capgo/capacitor-alarm 7.0.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/CapgoCapacitorAlarm.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +159 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/capacitor/alarm/CapgoAlarmPlugin.java +107 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +228 -0
- package/dist/esm/definitions.d.ts +59 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +10 -0
- package/dist/esm/web.js +21 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +35 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +38 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/CapgoAlarmPlugin/AlarmKitBridge.swift +57 -0
- package/ios/Sources/CapgoAlarmPlugin/CapgoAlarmPlugin.swift +67 -0
- package/ios/Tests/CapgoAlarmPluginTests/CapgoAlarmPluginTests.swift +15 -0
- package/package.json +80 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapgoCapacitorAlarm'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapgoCapacitorAlarm",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapgoCapacitorAlarm",
|
|
10
|
+
targets: ["CapgoAlarmPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "CapgoAlarmPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/CapgoAlarmPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "CapgoAlarmPluginTests",
|
|
25
|
+
dependencies: ["CapgoAlarmPlugin"],
|
|
26
|
+
path: "ios/Tests/CapgoAlarmPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @capgo/capacitor-alarm
|
|
2
|
+
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
6
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
Manage native alarm Capacitor plugin
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @capgo/capacitor-alarm
|
|
15
|
+
npx cap sync
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- iOS: iOS 26+ only. This plugin relies on AlarmKit APIs and will report unsupported on earlier versions or when the framework is unavailable.
|
|
21
|
+
- Android: Uses `AlarmClock` intents; behavior depends on the default Clock app and OEM policies.
|
|
22
|
+
|
|
23
|
+
Note: This plugin only exposes native alarm actions (create/open). It does not implement any custom in-app alarm scheduling/CRUD.
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
<docgen-index>
|
|
28
|
+
|
|
29
|
+
* [`createAlarm(...)`](#createalarm)
|
|
30
|
+
* [`openAlarms()`](#openalarms)
|
|
31
|
+
* [`getOSInfo()`](#getosinfo)
|
|
32
|
+
* [`requestPermissions(...)`](#requestpermissions)
|
|
33
|
+
* [Interfaces](#interfaces)
|
|
34
|
+
* [Type Aliases](#type-aliases)
|
|
35
|
+
|
|
36
|
+
</docgen-index>
|
|
37
|
+
|
|
38
|
+
<docgen-api>
|
|
39
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
40
|
+
|
|
41
|
+
### createAlarm(...)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
createAlarm(options: NativeAlarmCreateOptions) => Promise<NativeActionResult>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Create a native OS alarm using the platform clock app.
|
|
48
|
+
On Android this uses the Alarm Clock intent; on iOS this is not supported.
|
|
49
|
+
|
|
50
|
+
| Param | Type |
|
|
51
|
+
| ------------- | ----------------------------------------------------------------------------- |
|
|
52
|
+
| **`options`** | <code><a href="#nativealarmcreateoptions">NativeAlarmCreateOptions</a></code> |
|
|
53
|
+
|
|
54
|
+
**Returns:** <code>Promise<<a href="#nativeactionresult">NativeActionResult</a>></code>
|
|
55
|
+
|
|
56
|
+
--------------------
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### openAlarms()
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
openAlarms() => Promise<NativeActionResult>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Open the platform's native alarm list UI, if available.
|
|
66
|
+
|
|
67
|
+
**Returns:** <code>Promise<<a href="#nativeactionresult">NativeActionResult</a>></code>
|
|
68
|
+
|
|
69
|
+
--------------------
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### getOSInfo()
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
getOSInfo() => Promise<OSInfo>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Get information about the OS and capabilities.
|
|
79
|
+
|
|
80
|
+
**Returns:** <code>Promise<<a href="#osinfo">OSInfo</a>></code>
|
|
81
|
+
|
|
82
|
+
--------------------
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### requestPermissions(...)
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
requestPermissions(options?: { exactAlarm?: boolean | undefined; } | undefined) => Promise<PermissionResult>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Request relevant permissions for alarm usage on the platform.
|
|
92
|
+
On Android, may route to settings for exact alarms.
|
|
93
|
+
|
|
94
|
+
| Param | Type |
|
|
95
|
+
| ------------- | -------------------------------------- |
|
|
96
|
+
| **`options`** | <code>{ exactAlarm?: boolean; }</code> |
|
|
97
|
+
|
|
98
|
+
**Returns:** <code>Promise<<a href="#permissionresult">PermissionResult</a>></code>
|
|
99
|
+
|
|
100
|
+
--------------------
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Interfaces
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
#### NativeActionResult
|
|
107
|
+
|
|
108
|
+
| Prop | Type |
|
|
109
|
+
| ------------- | -------------------- |
|
|
110
|
+
| **`success`** | <code>boolean</code> |
|
|
111
|
+
| **`message`** | <code>string</code> |
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
#### NativeAlarmCreateOptions
|
|
115
|
+
|
|
116
|
+
Options for creating a native OS alarm via the platform clock app.
|
|
117
|
+
|
|
118
|
+
| Prop | Type | Description |
|
|
119
|
+
| ------------- | -------------------- | -------------------------------------------- |
|
|
120
|
+
| **`hour`** | <code>number</code> | Hour of day in 24h format (0-23) |
|
|
121
|
+
| **`minute`** | <code>number</code> | Minute of hour (0-59) |
|
|
122
|
+
| **`label`** | <code>string</code> | Optional label for the alarm |
|
|
123
|
+
| **`skipUi`** | <code>boolean</code> | Android only: attempt to skip UI if possible |
|
|
124
|
+
| **`vibrate`** | <code>boolean</code> | Android only: set alarm to vibrate |
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
#### OSInfo
|
|
128
|
+
|
|
129
|
+
Returned info about current OS and capabilities.
|
|
130
|
+
|
|
131
|
+
| Prop | Type | Description |
|
|
132
|
+
| ------------------------------------ | -------------------- | ----------------------------------------------------------- |
|
|
133
|
+
| **`platform`** | <code>string</code> | 'ios' \| 'android' \| 'web' |
|
|
134
|
+
| **`version`** | <code>string</code> | OS version string |
|
|
135
|
+
| **`supportsNativeAlarms`** | <code>boolean</code> | Whether the platform exposes a native alarm app integration |
|
|
136
|
+
| **`supportsScheduledNotifications`** | <code>boolean</code> | Whether scheduling local notifications is supported |
|
|
137
|
+
| **`canScheduleExactAlarms`** | <code>boolean</code> | Android only: whether exact alarms are allowed |
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
#### PermissionResult
|
|
141
|
+
|
|
142
|
+
Result of a permissions request.
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Description |
|
|
145
|
+
| ------------- | ---------------------------------------------------------------- | ---------------------------------- |
|
|
146
|
+
| **`granted`** | <code>boolean</code> | Overall grant for requested scope |
|
|
147
|
+
| **`details`** | <code><a href="#record">Record</a><string, boolean></code> | Optional details by permission key |
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### Type Aliases
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
#### Record
|
|
154
|
+
|
|
155
|
+
Construct a type with a set of properties K of type T
|
|
156
|
+
|
|
157
|
+
<code>{
|
|
158
|
[P in K]: T;
|
|
1
159
|
}</code>
|
|
160
|
+
|
|
161
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "app.capgo.capacitor.alarm"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package app.capgo.capacitor.alarm;
|
|
2
|
+
|
|
3
|
+
import android.app.AlarmManager;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
6
|
+
import android.os.Build;
|
|
7
|
+
import android.provider.AlarmClock;
|
|
8
|
+
import com.getcapacitor.JSObject;
|
|
9
|
+
import com.getcapacitor.Plugin;
|
|
10
|
+
import com.getcapacitor.PluginCall;
|
|
11
|
+
import com.getcapacitor.PluginMethod;
|
|
12
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
13
|
+
|
|
14
|
+
@CapacitorPlugin(name = "CapgoAlarm")
|
|
15
|
+
public class CapgoAlarmPlugin extends Plugin {
|
|
16
|
+
|
|
17
|
+
// ===== Native OS Alarm helpers (Android) =====
|
|
18
|
+
@PluginMethod
|
|
19
|
+
public void createAlarm(PluginCall call) {
|
|
20
|
+
Integer hour = call.getInt("hour");
|
|
21
|
+
Integer minute = call.getInt("minute");
|
|
22
|
+
if (hour == null || minute == null) {
|
|
23
|
+
call.reject("hour and minute are required");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
String label = call.getString("label");
|
|
27
|
+
boolean skipUi = call.getBoolean("skipUi", false);
|
|
28
|
+
boolean vibrate = call.getBoolean("vibrate", false);
|
|
29
|
+
|
|
30
|
+
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
|
|
31
|
+
.putExtra(AlarmClock.EXTRA_HOUR, hour)
|
|
32
|
+
.putExtra(AlarmClock.EXTRA_MINUTES, minute)
|
|
33
|
+
.putExtra(AlarmClock.EXTRA_VIBRATE, vibrate);
|
|
34
|
+
if (label != null) intent.putExtra(AlarmClock.EXTRA_MESSAGE, label);
|
|
35
|
+
if (skipUi) intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
|
|
36
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
getContext().startActivity(intent);
|
|
40
|
+
JSObject ret = new JSObject();
|
|
41
|
+
ret.put("success", true);
|
|
42
|
+
call.resolve(ret);
|
|
43
|
+
} catch (Exception e) {
|
|
44
|
+
JSObject ret = new JSObject();
|
|
45
|
+
ret.put("success", false);
|
|
46
|
+
ret.put("message", e.getMessage());
|
|
47
|
+
call.resolve(ret);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@PluginMethod
|
|
52
|
+
public void openAlarms(PluginCall call) {
|
|
53
|
+
Intent intent = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
|
|
54
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
55
|
+
try {
|
|
56
|
+
getContext().startActivity(intent);
|
|
57
|
+
JSObject ret = new JSObject();
|
|
58
|
+
ret.put("success", true);
|
|
59
|
+
call.resolve(ret);
|
|
60
|
+
} catch (Exception e) {
|
|
61
|
+
JSObject ret = new JSObject();
|
|
62
|
+
ret.put("success", false);
|
|
63
|
+
ret.put("message", e.getMessage());
|
|
64
|
+
call.resolve(ret);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@PluginMethod
|
|
69
|
+
public void getOSInfo(PluginCall call) {
|
|
70
|
+
JSObject ret = new JSObject();
|
|
71
|
+
ret.put("platform", "android");
|
|
72
|
+
ret.put("version", Build.VERSION.RELEASE);
|
|
73
|
+
ret.put("supportsNativeAlarms", true);
|
|
74
|
+
ret.put("supportsScheduledNotifications", true);
|
|
75
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
76
|
+
AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
|
|
77
|
+
boolean can = am != null && am.canScheduleExactAlarms();
|
|
78
|
+
ret.put("canScheduleExactAlarms", can);
|
|
79
|
+
}
|
|
80
|
+
call.resolve(ret);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@PluginMethod
|
|
84
|
+
public void requestPermissions(PluginCall call) {
|
|
85
|
+
boolean requestExact = call.getBoolean("exactAlarm", false);
|
|
86
|
+
JSObject ret = new JSObject();
|
|
87
|
+
if (requestExact && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
88
|
+
AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
|
|
89
|
+
boolean can = am != null && am.canScheduleExactAlarms();
|
|
90
|
+
if (!can) {
|
|
91
|
+
Intent i = new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
|
|
92
|
+
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
93
|
+
try {
|
|
94
|
+
getContext().startActivity(i);
|
|
95
|
+
} catch (Exception ignored) {}
|
|
96
|
+
ret.put("granted", false);
|
|
97
|
+
JSObject details = new JSObject();
|
|
98
|
+
details.put("exactAlarm", false);
|
|
99
|
+
ret.put("details", details);
|
|
100
|
+
call.resolve(ret);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
ret.put("granted", true);
|
|
105
|
+
call.resolve(ret);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "CapgoAlarmPlugin",
|
|
4
|
+
"slug": "capgoalarmplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "createAlarm",
|
|
10
|
+
"signature": "(options: NativeAlarmCreateOptions) => Promise<NativeActionResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "NativeAlarmCreateOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<NativeActionResult>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "Create a native OS alarm using the platform clock app.\nOn Android this uses the Alarm Clock intent; on iOS this is not supported.",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"NativeActionResult",
|
|
23
|
+
"NativeAlarmCreateOptions"
|
|
24
|
+
],
|
|
25
|
+
"slug": "createalarm"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "openAlarms",
|
|
29
|
+
"signature": "() => Promise<NativeActionResult>",
|
|
30
|
+
"parameters": [],
|
|
31
|
+
"returns": "Promise<NativeActionResult>",
|
|
32
|
+
"tags": [],
|
|
33
|
+
"docs": "Open the platform's native alarm list UI, if available.",
|
|
34
|
+
"complexTypes": [
|
|
35
|
+
"NativeActionResult"
|
|
36
|
+
],
|
|
37
|
+
"slug": "openalarms"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "getOSInfo",
|
|
41
|
+
"signature": "() => Promise<OSInfo>",
|
|
42
|
+
"parameters": [],
|
|
43
|
+
"returns": "Promise<OSInfo>",
|
|
44
|
+
"tags": [],
|
|
45
|
+
"docs": "Get information about the OS and capabilities.",
|
|
46
|
+
"complexTypes": [
|
|
47
|
+
"OSInfo"
|
|
48
|
+
],
|
|
49
|
+
"slug": "getosinfo"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "requestPermissions",
|
|
53
|
+
"signature": "(options?: { exactAlarm?: boolean | undefined; } | undefined) => Promise<PermissionResult>",
|
|
54
|
+
"parameters": [
|
|
55
|
+
{
|
|
56
|
+
"name": "options",
|
|
57
|
+
"docs": "",
|
|
58
|
+
"type": "{ exactAlarm?: boolean | undefined; } | undefined"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"returns": "Promise<PermissionResult>",
|
|
62
|
+
"tags": [],
|
|
63
|
+
"docs": "Request relevant permissions for alarm usage on the platform.\nOn Android, may route to settings for exact alarms.",
|
|
64
|
+
"complexTypes": [
|
|
65
|
+
"PermissionResult"
|
|
66
|
+
],
|
|
67
|
+
"slug": "requestpermissions"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"properties": []
|
|
71
|
+
},
|
|
72
|
+
"interfaces": [
|
|
73
|
+
{
|
|
74
|
+
"name": "NativeActionResult",
|
|
75
|
+
"slug": "nativeactionresult",
|
|
76
|
+
"docs": "",
|
|
77
|
+
"tags": [],
|
|
78
|
+
"methods": [],
|
|
79
|
+
"properties": [
|
|
80
|
+
{
|
|
81
|
+
"name": "success",
|
|
82
|
+
"tags": [],
|
|
83
|
+
"docs": "",
|
|
84
|
+
"complexTypes": [],
|
|
85
|
+
"type": "boolean"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "message",
|
|
89
|
+
"tags": [],
|
|
90
|
+
"docs": "",
|
|
91
|
+
"complexTypes": [],
|
|
92
|
+
"type": "string | undefined"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "NativeAlarmCreateOptions",
|
|
98
|
+
"slug": "nativealarmcreateoptions",
|
|
99
|
+
"docs": "Options for creating a native OS alarm via the platform clock app.",
|
|
100
|
+
"tags": [],
|
|
101
|
+
"methods": [],
|
|
102
|
+
"properties": [
|
|
103
|
+
{
|
|
104
|
+
"name": "hour",
|
|
105
|
+
"tags": [],
|
|
106
|
+
"docs": "Hour of day in 24h format (0-23)",
|
|
107
|
+
"complexTypes": [],
|
|
108
|
+
"type": "number"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "minute",
|
|
112
|
+
"tags": [],
|
|
113
|
+
"docs": "Minute of hour (0-59)",
|
|
114
|
+
"complexTypes": [],
|
|
115
|
+
"type": "number"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "label",
|
|
119
|
+
"tags": [],
|
|
120
|
+
"docs": "Optional label for the alarm",
|
|
121
|
+
"complexTypes": [],
|
|
122
|
+
"type": "string | undefined"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "skipUi",
|
|
126
|
+
"tags": [],
|
|
127
|
+
"docs": "Android only: attempt to skip UI if possible",
|
|
128
|
+
"complexTypes": [],
|
|
129
|
+
"type": "boolean | undefined"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "vibrate",
|
|
133
|
+
"tags": [],
|
|
134
|
+
"docs": "Android only: set alarm to vibrate",
|
|
135
|
+
"complexTypes": [],
|
|
136
|
+
"type": "boolean | undefined"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "OSInfo",
|
|
142
|
+
"slug": "osinfo",
|
|
143
|
+
"docs": "Returned info about current OS and capabilities.",
|
|
144
|
+
"tags": [],
|
|
145
|
+
"methods": [],
|
|
146
|
+
"properties": [
|
|
147
|
+
{
|
|
148
|
+
"name": "platform",
|
|
149
|
+
"tags": [],
|
|
150
|
+
"docs": "'ios' | 'android' | 'web'",
|
|
151
|
+
"complexTypes": [],
|
|
152
|
+
"type": "string"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "version",
|
|
156
|
+
"tags": [],
|
|
157
|
+
"docs": "OS version string",
|
|
158
|
+
"complexTypes": [],
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "supportsNativeAlarms",
|
|
163
|
+
"tags": [],
|
|
164
|
+
"docs": "Whether the platform exposes a native alarm app integration",
|
|
165
|
+
"complexTypes": [],
|
|
166
|
+
"type": "boolean"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "supportsScheduledNotifications",
|
|
170
|
+
"tags": [],
|
|
171
|
+
"docs": "Whether scheduling local notifications is supported",
|
|
172
|
+
"complexTypes": [],
|
|
173
|
+
"type": "boolean"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "canScheduleExactAlarms",
|
|
177
|
+
"tags": [],
|
|
178
|
+
"docs": "Android only: whether exact alarms are allowed",
|
|
179
|
+
"complexTypes": [],
|
|
180
|
+
"type": "boolean | undefined"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "PermissionResult",
|
|
186
|
+
"slug": "permissionresult",
|
|
187
|
+
"docs": "Result of a permissions request.",
|
|
188
|
+
"tags": [],
|
|
189
|
+
"methods": [],
|
|
190
|
+
"properties": [
|
|
191
|
+
{
|
|
192
|
+
"name": "granted",
|
|
193
|
+
"tags": [],
|
|
194
|
+
"docs": "Overall grant for requested scope",
|
|
195
|
+
"complexTypes": [],
|
|
196
|
+
"type": "boolean"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "details",
|
|
200
|
+
"tags": [],
|
|
201
|
+
"docs": "Optional details by permission key",
|
|
202
|
+
"complexTypes": [
|
|
203
|
+
"Record"
|
|
204
|
+
],
|
|
205
|
+
"type": "Record<string, boolean>"
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"enums": [],
|
|
211
|
+
"typeAliases": [
|
|
212
|
+
{
|
|
213
|
+
"name": "Record",
|
|
214
|
+
"slug": "record",
|
|
215
|
+
"docs": "Construct a type with a set of properties K of type T",
|
|
216
|
+
"types": [
|
|
217
|
+
{
|
|
218
|
+
"text": "{\r\n [P in K]: T;\r\n}",
|
|
219
|
+
"complexTypes": [
|
|
220
|
+
"K",
|
|
221
|
+
"T"
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
"pluginConfigs": []
|
|
228
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Options for creating a native OS alarm via the platform clock app. */
|
|
2
|
+
export interface NativeAlarmCreateOptions {
|
|
3
|
+
/** Hour of day in 24h format (0-23) */
|
|
4
|
+
hour: number;
|
|
5
|
+
/** Minute of hour (0-59) */
|
|
6
|
+
minute: number;
|
|
7
|
+
/** Optional label for the alarm */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Android only: attempt to skip UI if possible */
|
|
10
|
+
skipUi?: boolean;
|
|
11
|
+
/** Android only: set alarm to vibrate */
|
|
12
|
+
vibrate?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NativeActionResult {
|
|
15
|
+
success: boolean;
|
|
16
|
+
message?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Returned info about current OS and capabilities. */
|
|
19
|
+
export interface OSInfo {
|
|
20
|
+
/** 'ios' | 'android' | 'web' */
|
|
21
|
+
platform: string;
|
|
22
|
+
/** OS version string */
|
|
23
|
+
version: string;
|
|
24
|
+
/** Whether the platform exposes a native alarm app integration */
|
|
25
|
+
supportsNativeAlarms: boolean;
|
|
26
|
+
/** Whether scheduling local notifications is supported */
|
|
27
|
+
supportsScheduledNotifications: boolean;
|
|
28
|
+
/** Android only: whether exact alarms are allowed */
|
|
29
|
+
canScheduleExactAlarms?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Result of a permissions request. */
|
|
32
|
+
export interface PermissionResult {
|
|
33
|
+
/** Overall grant for requested scope */
|
|
34
|
+
granted: boolean;
|
|
35
|
+
/** Optional details by permission key */
|
|
36
|
+
details?: Record<string, boolean>;
|
|
37
|
+
}
|
|
38
|
+
export interface CapgoAlarmPlugin {
|
|
39
|
+
/**
|
|
40
|
+
* Create a native OS alarm using the platform clock app.
|
|
41
|
+
* On Android this uses the Alarm Clock intent; on iOS this is not supported.
|
|
42
|
+
*/
|
|
43
|
+
createAlarm(options: NativeAlarmCreateOptions): Promise<NativeActionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Open the platform's native alarm list UI, if available.
|
|
46
|
+
*/
|
|
47
|
+
openAlarms(): Promise<NativeActionResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Get information about the OS and capabilities.
|
|
50
|
+
*/
|
|
51
|
+
getOSInfo(): Promise<OSInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* Request relevant permissions for alarm usage on the platform.
|
|
54
|
+
* On Android, may route to settings for exact alarms.
|
|
55
|
+
*/
|
|
56
|
+
requestPermissions(options?: {
|
|
57
|
+
exactAlarm?: boolean;
|
|
58
|
+
}): Promise<PermissionResult>;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/** Options for creating a native OS alarm via the platform clock app. */\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\nexport interface NativeActionResult {\n success: boolean;\n message?: string;\n}\n\n/** Returned info about current OS and capabilities. */\nexport interface OSInfo {\n /** '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/** Result of a permissions request. */\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\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 is not supported.\n */\n createAlarm(options: NativeAlarmCreateOptions): Promise<NativeActionResult>;\n\n /**\n * Open the platform's native alarm list UI, if available.\n */\n openAlarms(): Promise<NativeActionResult>;\n\n /**\n * Get information about the OS and capabilities.\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 requestPermissions(options?: { exactAlarm?: boolean }): Promise<PermissionResult>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapgoAlarmPlugin } from './definitions';\n\nconst CapgoAlarm = registerPlugin<CapgoAlarmPlugin>('CapgoAlarm', {\n web: () => import('./web').then((m) => new m.CapgoAlarmWeb()),\n});\n\nexport * from './definitions';\nexport { CapgoAlarm };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { CapgoAlarmPlugin, NativeAlarmCreateOptions, NativeActionResult, OSInfo, PermissionResult } from './definitions';
|
|
3
|
+
export declare class CapgoAlarmWeb extends WebPlugin implements CapgoAlarmPlugin {
|
|
4
|
+
createAlarm(_options: NativeAlarmCreateOptions): Promise<NativeActionResult>;
|
|
5
|
+
openAlarms(): Promise<NativeActionResult>;
|
|
6
|
+
getOSInfo(): Promise<OSInfo>;
|
|
7
|
+
requestPermissions(_options?: {
|
|
8
|
+
exactAlarm?: boolean;
|
|
9
|
+
}): Promise<PermissionResult>;
|
|
10
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class CapgoAlarmWeb extends WebPlugin {
|
|
3
|
+
async createAlarm(_options) {
|
|
4
|
+
return { success: false, message: 'Native alarm not supported on web' };
|
|
5
|
+
}
|
|
6
|
+
async openAlarms() {
|
|
7
|
+
return { success: false, message: 'Native alarm UI not available on web' };
|
|
8
|
+
}
|
|
9
|
+
async getOSInfo() {
|
|
10
|
+
return {
|
|
11
|
+
platform: 'web',
|
|
12
|
+
version: navigator.userAgent,
|
|
13
|
+
supportsNativeAlarms: false,
|
|
14
|
+
supportsScheduledNotifications: false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async requestPermissions(_options) {
|
|
18
|
+
return { granted: true };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,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;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CapgoAlarmPlugin,\n NativeAlarmCreateOptions,\n NativeActionResult,\n OSInfo,\n PermissionResult,\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"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const CapgoAlarm = core.registerPlugin('CapgoAlarm', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapgoAlarmWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class CapgoAlarmWeb extends core.WebPlugin {
|
|
10
|
+
async createAlarm(_options) {
|
|
11
|
+
return { success: false, message: 'Native alarm not supported on web' };
|
|
12
|
+
}
|
|
13
|
+
async openAlarms() {
|
|
14
|
+
return { success: false, message: 'Native alarm UI not available on web' };
|
|
15
|
+
}
|
|
16
|
+
async getOSInfo() {
|
|
17
|
+
return {
|
|
18
|
+
platform: 'web',
|
|
19
|
+
version: navigator.userAgent,
|
|
20
|
+
supportsNativeAlarms: false,
|
|
21
|
+
supportsScheduledNotifications: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async requestPermissions(_options) {
|
|
25
|
+
return { granted: true };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
30
|
+
__proto__: null,
|
|
31
|
+
CapgoAlarmWeb: CapgoAlarmWeb
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
exports.CapgoAlarm = CapgoAlarm;
|
|
35
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +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}\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;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var capacitorCapgoAlarm = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CapgoAlarm = core.registerPlugin('CapgoAlarm', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapgoAlarmWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class CapgoAlarmWeb extends core.WebPlugin {
|
|
9
|
+
async createAlarm(_options) {
|
|
10
|
+
return { success: false, message: 'Native alarm not supported on web' };
|
|
11
|
+
}
|
|
12
|
+
async openAlarms() {
|
|
13
|
+
return { success: false, message: 'Native alarm UI not available on web' };
|
|
14
|
+
}
|
|
15
|
+
async getOSInfo() {
|
|
16
|
+
return {
|
|
17
|
+
platform: 'web',
|
|
18
|
+
version: navigator.userAgent,
|
|
19
|
+
supportsNativeAlarms: false,
|
|
20
|
+
supportsScheduledNotifications: false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async requestPermissions(_options) {
|
|
24
|
+
return { granted: true };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
29
|
+
__proto__: null,
|
|
30
|
+
CapgoAlarmWeb: CapgoAlarmWeb
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
exports.CapgoAlarm = CapgoAlarm;
|
|
34
|
+
|
|
35
|
+
return exports;
|
|
36
|
+
|
|
37
|
+
})({}, capacitorExports);
|
|
38
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +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}\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;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
#if canImport(AlarmKit)
|
|
4
|
+
import AlarmKit
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
class AlarmKitBridge {
|
|
8
|
+
static func isAvailable() -> Bool {
|
|
9
|
+
#if canImport(AlarmKit)
|
|
10
|
+
if #available(iOS 26.0, *) { return true } else { return false }
|
|
11
|
+
#else
|
|
12
|
+
return false
|
|
13
|
+
#endif
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static func requestAuthorization(completion: @escaping (Bool, String?) -> Void) {
|
|
17
|
+
#if canImport(AlarmKit)
|
|
18
|
+
if #available(iOS 26.0, *) {
|
|
19
|
+
Task {
|
|
20
|
+
do {
|
|
21
|
+
// Acquire the AlarmKit manager; many Apple frameworks use a shared singleton.
|
|
22
|
+
let alarmManager = AlarmManager.shared
|
|
23
|
+
let state = try await alarmManager.requestAuthorization()
|
|
24
|
+
completion(state == .authorized, nil)
|
|
25
|
+
} catch {
|
|
26
|
+
completion(false, "Authorization error: \(error.localizedDescription)")
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
completion(false, "AlarmKit not available on this device/SDK")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static func createAlarm(hour: Int, minute: Int, label: String?, completion: @escaping (Bool, String?) -> Void) {
|
|
36
|
+
#if canImport(AlarmKit)
|
|
37
|
+
if #available(iOS 26.0, *) {
|
|
38
|
+
// TODO: Replace with real AlarmKit calls.
|
|
39
|
+
// We intentionally avoid guessing API surface to prevent compilation/runtime issues.
|
|
40
|
+
completion(false, "AlarmKit integrated but no concrete API wired. Provide exact AlarmKit API usage.")
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
#endif
|
|
44
|
+
completion(false, "AlarmKit not available on this device/SDK")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static func openAlarms(completion: @escaping (Bool, String?) -> Void) {
|
|
48
|
+
#if canImport(AlarmKit)
|
|
49
|
+
if #available(iOS 26.0, *) {
|
|
50
|
+
// TODO: Replace with real AlarmKit calls.
|
|
51
|
+
completion(false, "AlarmKit integrated but no concrete API wired. Provide exact AlarmKit API usage.")
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
#endif
|
|
55
|
+
completion(false, "AlarmKit not available on this device/SDK")
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(CapgoAlarmPlugin)
|
|
9
|
+
public class CapgoAlarmPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
+
public let identifier = "CapgoAlarmPlugin"
|
|
11
|
+
public let jsName = "CapgoAlarm"
|
|
12
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
13
|
+
CAPPluginMethod(name: "createAlarm", returnType: CAPPluginReturnPromise),
|
|
14
|
+
CAPPluginMethod(name: "openAlarms", returnType: CAPPluginReturnPromise),
|
|
15
|
+
CAPPluginMethod(name: "getOSInfo", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise)
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
@objc func createAlarm(_ call: CAPPluginCall) {
|
|
20
|
+
let hour = call.getInt("hour") ?? -1
|
|
21
|
+
let minute = call.getInt("minute") ?? -1
|
|
22
|
+
if hour < 0 || minute < 0 { call.reject("hour and minute are required"); return }
|
|
23
|
+
let label = call.getString("label")
|
|
24
|
+
|
|
25
|
+
AlarmKitBridge.createAlarm(hour: hour, minute: minute, label: label) { success, message in
|
|
26
|
+
call.resolve(["success": success, "message": message ?? NSNull()])
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@objc func openAlarms(_ call: CAPPluginCall) {
|
|
31
|
+
AlarmKitBridge.openAlarms { success, message in
|
|
32
|
+
call.resolve(["success": success, "message": message ?? NSNull()])
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@objc func getOSInfo(_ call: CAPPluginCall) {
|
|
37
|
+
let version = UIDevice.current.systemVersion
|
|
38
|
+
let supportsNative = AlarmKitBridge.isAvailable()
|
|
39
|
+
call.resolve([
|
|
40
|
+
"platform": "ios",
|
|
41
|
+
"version": version,
|
|
42
|
+
"supportsNativeAlarms": supportsNative,
|
|
43
|
+
"supportsScheduledNotifications": true
|
|
44
|
+
])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Capacitor permission lifecycle
|
|
48
|
+
public override func checkPermissions(_ call: CAPPluginCall) {
|
|
49
|
+
// No explicit runtime permission needed for AlarmKit; always granted when available
|
|
50
|
+
call.resolve(["granted": true])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public override func requestPermissions(_ call: CAPPluginCall) {
|
|
54
|
+
// Request AlarmKit authorization when available
|
|
55
|
+
if !AlarmKitBridge.isAvailable() {
|
|
56
|
+
call.resolve(["granted": false])
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
AlarmKitBridge.requestAuthorization { granted, message in
|
|
60
|
+
var result: [String: Any] = ["granted": granted]
|
|
61
|
+
if let message = message { result["message"] = message }
|
|
62
|
+
call.resolve(result)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// No data conversion helpers needed for native-only operations
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import CapgoAlarmPlugin
|
|
3
|
+
|
|
4
|
+
class CapgoAlarmTests: XCTestCase {
|
|
5
|
+
func testEcho() {
|
|
6
|
+
// This is an example of a functional test case for a plugin.
|
|
7
|
+
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
8
|
+
|
|
9
|
+
let implementation = CapgoAlarm()
|
|
10
|
+
let value = "Hello, World!"
|
|
11
|
+
let result = implementation.echo(value)
|
|
12
|
+
|
|
13
|
+
XCTAssertEqual(value, result)
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capgo/capacitor-alarm",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "Manage native alarm Capacitor plugin",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"CapgoCapacitorAlarm.podspec"
|
|
17
|
+
],
|
|
18
|
+
"author": "Martin Donadieu <martin@capgo.app>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Cap-go/capacitor-alarm.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Cap-go/capacitor-alarm/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"plugin",
|
|
30
|
+
"native"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
34
|
+
"verify:ios": "xcodebuild -scheme CapgoCapacitorAlarm -destination generic/platform=iOS",
|
|
35
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
|
+
"verify:web": "npm run build",
|
|
37
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
39
|
+
"eslint": "eslint . --ext ts",
|
|
40
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
|
+
"swiftlint": "node-swiftlint",
|
|
42
|
+
"docgen": "docgen --api CapgoAlarmPlugin --output-readme README.md --output-json dist/docs.json",
|
|
43
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
44
|
+
"clean": "rimraf ./dist",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@capacitor/android": "^7.0.0",
|
|
50
|
+
"@capacitor/core": "^7.0.0",
|
|
51
|
+
"@capacitor/docgen": "^0.3.0",
|
|
52
|
+
"@capacitor/ios": "^7.0.0",
|
|
53
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
54
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
55
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
|
+
"prettier-plugin-java": "^2.6.6",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"rollup": "^4.30.1",
|
|
61
|
+
"swiftlint": "^2.0.0",
|
|
62
|
+
"typescript": "~4.1.5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@capacitor/core": ">=7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": "@ionic/prettier-config",
|
|
68
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
71
|
+
},
|
|
72
|
+
"capacitor": {
|
|
73
|
+
"ios": {
|
|
74
|
+
"src": "ios"
|
|
75
|
+
},
|
|
76
|
+
"android": {
|
|
77
|
+
"src": "android"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|