@choochmeque/tauri-plugin-notifications-api 0.1.0 → 0.2.2
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 +67 -6
- package/dist-js/index.cjs +106 -44
- package/dist-js/index.d.ts +181 -59
- package/dist-js/index.js +106 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Tauri Plugin Notifications
|
|
6
6
|
|
|
7
|
-
A Tauri v2 plugin for sending
|
|
7
|
+
A Tauri v2 plugin for sending notifications on desktop and mobile platforms. Send toast notifications (brief auto-expiring OS window elements) with support for rich content, scheduling, actions, channels, and push delivery via FCM and APNs.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -46,6 +46,26 @@ Add the plugin to your Tauri project's `Cargo.toml`:
|
|
|
46
46
|
tauri-plugin-notifications = "0.1"
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
### Push Notifications Feature
|
|
50
|
+
|
|
51
|
+
The `push-notifications` feature is **disabled by default**. To enable push notifications support:
|
|
52
|
+
|
|
53
|
+
```toml
|
|
54
|
+
[dependencies]
|
|
55
|
+
tauri-plugin-notifications = { version = "0.1", features = ["push-notifications"] }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This enables:
|
|
59
|
+
- Firebase Cloud Messaging support on Android
|
|
60
|
+
- APNs (Apple Push Notification service) support on iOS
|
|
61
|
+
|
|
62
|
+
**Note:** Push notifications are currently supported on mobile platforms (iOS and Android) only. macOS and Windows support is not yet available.
|
|
63
|
+
|
|
64
|
+
Without this feature enabled:
|
|
65
|
+
- Firebase dependencies are not included in Android builds
|
|
66
|
+
- Push notification registration code is disabled
|
|
67
|
+
- The `registerForPushNotifications()` function will return an error if called
|
|
68
|
+
|
|
49
69
|
Configure the plugin permissions in your `capabilities/default.json`:
|
|
50
70
|
|
|
51
71
|
```json
|
|
@@ -308,20 +328,35 @@ const unlisten = await onNotificationReceived((notification) => {
|
|
|
308
328
|
unlisten();
|
|
309
329
|
```
|
|
310
330
|
|
|
331
|
+
#### Push Notifications (Mobile)
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { registerForPushNotifications } from '@choochmeque/tauri-plugin-notifications-api';
|
|
335
|
+
|
|
336
|
+
// Register for push notifications and get device token
|
|
337
|
+
try {
|
|
338
|
+
const token = await registerForPushNotifications();
|
|
339
|
+
console.log('Push token:', token);
|
|
340
|
+
// Send this token to your server to send push notifications
|
|
341
|
+
} catch (error) {
|
|
342
|
+
console.error('Failed to register for push notifications:', error);
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
311
346
|
### Rust
|
|
312
347
|
|
|
313
348
|
```rust
|
|
314
|
-
use tauri_plugin_notifications::{
|
|
349
|
+
use tauri_plugin_notifications::{NotificationsExt, Schedule, ScheduleEvery};
|
|
315
350
|
|
|
316
351
|
// Send simple notification
|
|
317
|
-
app.
|
|
352
|
+
app.notifications()
|
|
318
353
|
.builder()
|
|
319
354
|
.title("Hello")
|
|
320
355
|
.body("This is a notification from Rust!")
|
|
321
356
|
.show()?;
|
|
322
357
|
|
|
323
358
|
// Send rich notification
|
|
324
|
-
app.
|
|
359
|
+
app.notifications()
|
|
325
360
|
.builder()
|
|
326
361
|
.id(1)
|
|
327
362
|
.title("New Message")
|
|
@@ -332,7 +367,7 @@ app.notification()
|
|
|
332
367
|
.show()?;
|
|
333
368
|
|
|
334
369
|
// Scheduled notification
|
|
335
|
-
app.
|
|
370
|
+
app.notifications()
|
|
336
371
|
.builder()
|
|
337
372
|
.title("Reminder")
|
|
338
373
|
.body("Time for your meeting!")
|
|
@@ -342,7 +377,7 @@ app.notification()
|
|
|
342
377
|
// Notification with attachments
|
|
343
378
|
use tauri_plugin_notifications::Attachment;
|
|
344
379
|
|
|
345
|
-
app.
|
|
380
|
+
app.notifications()
|
|
346
381
|
.builder()
|
|
347
382
|
.title("Photo Shared")
|
|
348
383
|
.body("Check out this image!")
|
|
@@ -365,6 +400,11 @@ Requests the permission to send notifications.
|
|
|
365
400
|
|
|
366
401
|
**Returns:** `Promise<'granted' | 'denied' | 'default'>`
|
|
367
402
|
|
|
403
|
+
### `registerForPushNotifications()`
|
|
404
|
+
Registers the app for push notifications (mobile only). On Android, this retrieves the FCM device token. On iOS, this requests permissions and registers for remote notifications.
|
|
405
|
+
|
|
406
|
+
**Returns:** `Promise<string>` - The device push token
|
|
407
|
+
|
|
368
408
|
### `sendNotification(options: Options | string)`
|
|
369
409
|
Sends a notification to the user. Can be called with a simple string for the title or with a detailed options object.
|
|
370
410
|
|
|
@@ -506,6 +546,27 @@ Listens for notification action performed events.
|
|
|
506
546
|
3. For custom icons:
|
|
507
547
|
- Place icons in `res/drawable/` folder
|
|
508
548
|
- Reference by filename (without extension)
|
|
549
|
+
4. **For push notifications (FCM)** - These steps must be done in your Tauri app project:
|
|
550
|
+
- Create a Firebase project at [Firebase Console](https://console.firebase.google.com/)
|
|
551
|
+
- Download the `google-services.json` file from Firebase Console
|
|
552
|
+
- Place `google-services.json` in your Tauri app's `gen/android/app/` directory
|
|
553
|
+
- Add the Google Services classpath to your app's `gen/android/build.gradle.kts`:
|
|
554
|
+
```kotlin
|
|
555
|
+
buildscript {
|
|
556
|
+
repositories {
|
|
557
|
+
google()
|
|
558
|
+
mavenCentral()
|
|
559
|
+
}
|
|
560
|
+
dependencies {
|
|
561
|
+
classpath("com.google.gms:google-services:4.4.2")
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
- Apply the plugin at the bottom of `gen/android/app/build.gradle.kts`:
|
|
566
|
+
```kotlin
|
|
567
|
+
apply(plugin = "com.google.gms.google-services")
|
|
568
|
+
```
|
|
569
|
+
- The notification plugin already includes the Firebase Cloud Messaging dependency when the `push-notifications` feature is enabled
|
|
509
570
|
|
|
510
571
|
## Testing
|
|
511
572
|
|
package/dist-js/index.cjs
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@tauri-apps/api/core');
|
|
4
4
|
|
|
5
|
-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
6
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
-
// SPDX-License-Identifier: MIT
|
|
8
5
|
/**
|
|
9
6
|
* Send toast notifications (brief auto-expiring OS window element) to your user.
|
|
10
7
|
* Can also be used with the Notification Web API.
|
|
11
8
|
*
|
|
12
9
|
* @module
|
|
13
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Predefined intervals for repeating notifications.
|
|
13
|
+
*/
|
|
14
14
|
exports.ScheduleEvery = void 0;
|
|
15
15
|
(function (ScheduleEvery) {
|
|
16
16
|
ScheduleEvery["Year"] = "year";
|
|
@@ -25,7 +25,18 @@ exports.ScheduleEvery = void 0;
|
|
|
25
25
|
*/
|
|
26
26
|
ScheduleEvery["Second"] = "second";
|
|
27
27
|
})(exports.ScheduleEvery || (exports.ScheduleEvery = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Schedule configuration for notifications.
|
|
30
|
+
*/
|
|
28
31
|
class Schedule {
|
|
32
|
+
/**
|
|
33
|
+
* Creates a schedule to fire at a specific date and time.
|
|
34
|
+
*
|
|
35
|
+
* @param date - The date and time to fire the notification.
|
|
36
|
+
* @param repeating - Whether to repeat the notification at the same time daily.
|
|
37
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
38
|
+
* @returns A new Schedule instance.
|
|
39
|
+
*/
|
|
29
40
|
static at(date, repeating = false, allowWhileIdle = false) {
|
|
30
41
|
return {
|
|
31
42
|
at: { date, repeating, allowWhileIdle },
|
|
@@ -33,6 +44,13 @@ class Schedule {
|
|
|
33
44
|
every: undefined,
|
|
34
45
|
};
|
|
35
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a schedule using an interval configuration.
|
|
49
|
+
*
|
|
50
|
+
* @param interval - The interval configuration specifying when to fire.
|
|
51
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
52
|
+
* @returns A new Schedule instance.
|
|
53
|
+
*/
|
|
36
54
|
static interval(interval, allowWhileIdle = false) {
|
|
37
55
|
return {
|
|
38
56
|
at: undefined,
|
|
@@ -40,6 +58,14 @@ class Schedule {
|
|
|
40
58
|
every: undefined,
|
|
41
59
|
};
|
|
42
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a schedule to repeat at regular intervals.
|
|
63
|
+
*
|
|
64
|
+
* @param kind - The type of interval (year, month, week, day, hour, minute, second).
|
|
65
|
+
* @param count - The number of intervals between notifications.
|
|
66
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
67
|
+
* @returns A new Schedule instance.
|
|
68
|
+
*/
|
|
43
69
|
static every(kind, count, allowWhileIdle = false) {
|
|
44
70
|
return {
|
|
45
71
|
at: undefined,
|
|
@@ -48,29 +74,41 @@ class Schedule {
|
|
|
48
74
|
};
|
|
49
75
|
}
|
|
50
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The importance level of a notification channel (Android).
|
|
79
|
+
*/
|
|
51
80
|
exports.Importance = void 0;
|
|
52
81
|
(function (Importance) {
|
|
82
|
+
/** Does not show notifications. */
|
|
53
83
|
Importance[Importance["None"] = 0] = "None";
|
|
84
|
+
/** Shows notifications only in the notification shade, no sound, no visual interruption. */
|
|
54
85
|
Importance[Importance["Min"] = 1] = "Min";
|
|
86
|
+
/** Shows notifications everywhere, but is not intrusive. */
|
|
55
87
|
Importance[Importance["Low"] = 2] = "Low";
|
|
88
|
+
/** Shows notifications everywhere with sound. */
|
|
56
89
|
Importance[Importance["Default"] = 3] = "Default";
|
|
90
|
+
/** Shows notifications everywhere with sound and heads-up display. */
|
|
57
91
|
Importance[Importance["High"] = 4] = "High";
|
|
58
92
|
})(exports.Importance || (exports.Importance = {}));
|
|
93
|
+
/**
|
|
94
|
+
* The visibility of a notification on the lock screen (Android).
|
|
95
|
+
*/
|
|
59
96
|
exports.Visibility = void 0;
|
|
60
97
|
(function (Visibility) {
|
|
98
|
+
/** Do not show any part of this notification on the lock screen. */
|
|
61
99
|
Visibility[Visibility["Secret"] = -1] = "Secret";
|
|
100
|
+
/** Show the notification, but hide sensitive content on the lock screen. */
|
|
62
101
|
Visibility[Visibility["Private"] = 0] = "Private";
|
|
102
|
+
/** Show the entire notification on the lock screen. */
|
|
63
103
|
Visibility[Visibility["Public"] = 1] = "Public";
|
|
64
104
|
})(exports.Visibility || (exports.Visibility = {}));
|
|
65
105
|
/**
|
|
66
106
|
* Checks if the permission to send notifications is granted.
|
|
67
107
|
* @example
|
|
68
108
|
* ```typescript
|
|
69
|
-
* import { isPermissionGranted } from '@tauri-
|
|
109
|
+
* import { isPermissionGranted } from '@choochmeque/tauri-plugin-notifications-api';
|
|
70
110
|
* const permissionGranted = await isPermissionGranted();
|
|
71
111
|
* ```
|
|
72
|
-
*
|
|
73
|
-
* @since 2.0.0
|
|
74
112
|
*/
|
|
75
113
|
async function isPermissionGranted() {
|
|
76
114
|
return await core.invoke("plugin:notifications|is_permission_granted");
|
|
@@ -79,7 +117,7 @@ async function isPermissionGranted() {
|
|
|
79
117
|
* Requests the permission to send notifications.
|
|
80
118
|
* @example
|
|
81
119
|
* ```typescript
|
|
82
|
-
* import { isPermissionGranted, requestPermission } from '@tauri-
|
|
120
|
+
* import { isPermissionGranted, requestPermission } from '@choochmeque/tauri-plugin-notifications-api';
|
|
83
121
|
* let permissionGranted = await isPermissionGranted();
|
|
84
122
|
* if (!permissionGranted) {
|
|
85
123
|
* const permission = await requestPermission();
|
|
@@ -88,17 +126,30 @@ async function isPermissionGranted() {
|
|
|
88
126
|
* ```
|
|
89
127
|
*
|
|
90
128
|
* @returns A promise resolving to whether the user granted the permission or not.
|
|
91
|
-
*
|
|
92
|
-
* @since 2.0.0
|
|
93
129
|
*/
|
|
94
130
|
async function requestPermission() {
|
|
95
131
|
return await core.invoke("plugin:notifications|request_permission");
|
|
96
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Registers the app for push notifications (mobile).
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { registerForPushNotifications } from '@choochmeque/tauri-plugin-notifications-api';
|
|
139
|
+
* const token = await registerForPushNotifications();
|
|
140
|
+
* console.log('Push token:', token);
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @returns A promise resolving to the device push token.
|
|
144
|
+
*/
|
|
145
|
+
async function registerForPushNotifications() {
|
|
146
|
+
return await core.invoke("plugin:notifications|register_for_push_notifications");
|
|
147
|
+
}
|
|
97
148
|
/**
|
|
98
149
|
* Sends a notification to the user.
|
|
99
150
|
* @example
|
|
100
151
|
* ```typescript
|
|
101
|
-
* import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-
|
|
152
|
+
* import { isPermissionGranted, requestPermission, sendNotification } from '@choochmeque/tauri-plugin-notifications-api';
|
|
102
153
|
* let permissionGranted = await isPermissionGranted();
|
|
103
154
|
* if (!permissionGranted) {
|
|
104
155
|
* const permission = await requestPermission();
|
|
@@ -109,8 +160,6 @@ async function requestPermission() {
|
|
|
109
160
|
* sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' });
|
|
110
161
|
* }
|
|
111
162
|
* ```
|
|
112
|
-
*
|
|
113
|
-
* @since 2.0.0
|
|
114
163
|
*/
|
|
115
164
|
async function sendNotification(options) {
|
|
116
165
|
await core.invoke("plugin:notifications|notify", {
|
|
@@ -126,7 +175,7 @@ async function sendNotification(options) {
|
|
|
126
175
|
*
|
|
127
176
|
* @example
|
|
128
177
|
* ```typescript
|
|
129
|
-
* import { registerActionTypes } from '@tauri-
|
|
178
|
+
* import { registerActionTypes } from '@choochmeque/tauri-plugin-notifications-api';
|
|
130
179
|
* await registerActionTypes([{
|
|
131
180
|
* id: 'tauri',
|
|
132
181
|
* actions: [{
|
|
@@ -137,8 +186,6 @@ async function sendNotification(options) {
|
|
|
137
186
|
* ```
|
|
138
187
|
*
|
|
139
188
|
* @returns A promise indicating the success or failure of the operation.
|
|
140
|
-
*
|
|
141
|
-
* @since 2.0.0
|
|
142
189
|
*/
|
|
143
190
|
async function registerActionTypes(types) {
|
|
144
191
|
await core.invoke("plugin:notifications|register_action_types", { types });
|
|
@@ -148,13 +195,11 @@ async function registerActionTypes(types) {
|
|
|
148
195
|
*
|
|
149
196
|
* @example
|
|
150
197
|
* ```typescript
|
|
151
|
-
* import { pending } from '@tauri-
|
|
198
|
+
* import { pending } from '@choochmeque/tauri-plugin-notifications-api';
|
|
152
199
|
* const pendingNotifications = await pending();
|
|
153
200
|
* ```
|
|
154
201
|
*
|
|
155
202
|
* @returns A promise resolving to the list of pending notifications.
|
|
156
|
-
*
|
|
157
|
-
* @since 2.0.0
|
|
158
203
|
*/
|
|
159
204
|
async function pending() {
|
|
160
205
|
return await core.invoke("plugin:notifications|get_pending");
|
|
@@ -164,13 +209,11 @@ async function pending() {
|
|
|
164
209
|
*
|
|
165
210
|
* @example
|
|
166
211
|
* ```typescript
|
|
167
|
-
* import { cancel } from '@tauri-
|
|
212
|
+
* import { cancel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
168
213
|
* await cancel([-34234, 23432, 4311]);
|
|
169
214
|
* ```
|
|
170
215
|
*
|
|
171
216
|
* @returns A promise indicating the success or failure of the operation.
|
|
172
|
-
*
|
|
173
|
-
* @since 2.0.0
|
|
174
217
|
*/
|
|
175
218
|
async function cancel(notifications) {
|
|
176
219
|
await core.invoke("plugin:notifications|cancel", { notifications });
|
|
@@ -180,13 +223,11 @@ async function cancel(notifications) {
|
|
|
180
223
|
*
|
|
181
224
|
* @example
|
|
182
225
|
* ```typescript
|
|
183
|
-
* import { cancelAll } from '@tauri-
|
|
226
|
+
* import { cancelAll } from '@choochmeque/tauri-plugin-notifications-api';
|
|
184
227
|
* await cancelAll();
|
|
185
228
|
* ```
|
|
186
229
|
*
|
|
187
230
|
* @returns A promise indicating the success or failure of the operation.
|
|
188
|
-
*
|
|
189
|
-
* @since 2.0.0
|
|
190
231
|
*/
|
|
191
232
|
async function cancelAll() {
|
|
192
233
|
await core.invoke("plugin:notifications|cancel");
|
|
@@ -196,13 +237,11 @@ async function cancelAll() {
|
|
|
196
237
|
*
|
|
197
238
|
* @example
|
|
198
239
|
* ```typescript
|
|
199
|
-
* import { active } from '@tauri-
|
|
240
|
+
* import { active } from '@choochmeque/tauri-plugin-notifications-api';
|
|
200
241
|
* const activeNotifications = await active();
|
|
201
242
|
* ```
|
|
202
243
|
*
|
|
203
244
|
* @returns A promise resolving to the list of active notifications.
|
|
204
|
-
*
|
|
205
|
-
* @since 2.0.0
|
|
206
245
|
*/
|
|
207
246
|
async function active() {
|
|
208
247
|
return await core.invoke("plugin:notifications|get_active");
|
|
@@ -212,13 +251,11 @@ async function active() {
|
|
|
212
251
|
*
|
|
213
252
|
* @example
|
|
214
253
|
* ```typescript
|
|
215
|
-
* import {
|
|
216
|
-
* await
|
|
254
|
+
* import { removeActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
255
|
+
* await removeActive([{ id: 1 }, { id: 2, tag: 'news' }]);
|
|
217
256
|
* ```
|
|
218
257
|
*
|
|
219
258
|
* @returns A promise indicating the success or failure of the operation.
|
|
220
|
-
*
|
|
221
|
-
* @since 2.0.0
|
|
222
259
|
*/
|
|
223
260
|
async function removeActive(notifications) {
|
|
224
261
|
await core.invoke("plugin:notifications|remove_active", { notifications });
|
|
@@ -228,13 +265,11 @@ async function removeActive(notifications) {
|
|
|
228
265
|
*
|
|
229
266
|
* @example
|
|
230
267
|
* ```typescript
|
|
231
|
-
* import { removeAllActive } from '@tauri-
|
|
268
|
+
* import { removeAllActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
232
269
|
* await removeAllActive()
|
|
233
270
|
* ```
|
|
234
271
|
*
|
|
235
272
|
* @returns A promise indicating the success or failure of the operation.
|
|
236
|
-
*
|
|
237
|
-
* @since 2.0.0
|
|
238
273
|
*/
|
|
239
274
|
async function removeAllActive() {
|
|
240
275
|
await core.invoke("plugin:notifications|remove_active");
|
|
@@ -244,7 +279,7 @@ async function removeAllActive() {
|
|
|
244
279
|
*
|
|
245
280
|
* @example
|
|
246
281
|
* ```typescript
|
|
247
|
-
* import { createChannel, Importance, Visibility } from '@tauri-
|
|
282
|
+
* import { createChannel, Importance, Visibility } from '@choochmeque/tauri-plugin-notifications-api';
|
|
248
283
|
* await createChannel({
|
|
249
284
|
* id: 'new-messages',
|
|
250
285
|
* name: 'New Messages',
|
|
@@ -256,8 +291,6 @@ async function removeAllActive() {
|
|
|
256
291
|
* ```
|
|
257
292
|
*
|
|
258
293
|
* @returns A promise indicating the success or failure of the operation.
|
|
259
|
-
*
|
|
260
|
-
* @since 2.0.0
|
|
261
294
|
*/
|
|
262
295
|
async function createChannel(channel) {
|
|
263
296
|
await core.invoke("plugin:notifications|create_channel", { ...channel });
|
|
@@ -267,13 +300,11 @@ async function createChannel(channel) {
|
|
|
267
300
|
*
|
|
268
301
|
* @example
|
|
269
302
|
* ```typescript
|
|
270
|
-
* import { removeChannel } from '@tauri-
|
|
271
|
-
* await removeChannel();
|
|
303
|
+
* import { removeChannel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
304
|
+
* await removeChannel('new-messages');
|
|
272
305
|
* ```
|
|
273
306
|
*
|
|
274
307
|
* @returns A promise indicating the success or failure of the operation.
|
|
275
|
-
*
|
|
276
|
-
* @since 2.0.0
|
|
277
308
|
*/
|
|
278
309
|
async function removeChannel(id) {
|
|
279
310
|
await core.invoke("plugin:notifications|delete_channel", { id });
|
|
@@ -283,20 +314,50 @@ async function removeChannel(id) {
|
|
|
283
314
|
*
|
|
284
315
|
* @example
|
|
285
316
|
* ```typescript
|
|
286
|
-
* import { channels } from '@tauri-
|
|
317
|
+
* import { channels } from '@choochmeque/tauri-plugin-notifications-api';
|
|
287
318
|
* const notificationChannels = await channels();
|
|
288
319
|
* ```
|
|
289
320
|
*
|
|
290
321
|
* @returns A promise resolving to the list of notification channels.
|
|
291
|
-
*
|
|
292
|
-
* @since 2.0.0
|
|
293
322
|
*/
|
|
294
323
|
async function channels() {
|
|
295
324
|
return await core.invoke("plugin:notifications|listChannels");
|
|
296
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Registers a listener for incoming notifications.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* import { onNotificationReceived } from '@choochmeque/tauri-plugin-notifications-api';
|
|
332
|
+
* const unlisten = await onNotificationReceived((notification) => {
|
|
333
|
+
* console.log('Notification received:', notification);
|
|
334
|
+
* });
|
|
335
|
+
* // Later, to stop listening:
|
|
336
|
+
* // unlisten();
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @param cb - Callback function to handle received notifications.
|
|
340
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
341
|
+
*/
|
|
297
342
|
async function onNotificationReceived(cb) {
|
|
298
343
|
return await core.addPluginListener("notifications", "notification", cb);
|
|
299
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Registers a listener for notification action events.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* import { onAction } from '@choochmeque/tauri-plugin-notifications-api';
|
|
351
|
+
* const unlisten = await onAction((notification) => {
|
|
352
|
+
* console.log('Action performed on notification:', notification);
|
|
353
|
+
* });
|
|
354
|
+
* // Later, to stop listening:
|
|
355
|
+
* // unlisten();
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @param cb - Callback function to handle notification actions.
|
|
359
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
360
|
+
*/
|
|
300
361
|
async function onAction(cb) {
|
|
301
362
|
return await core.addPluginListener("notifications", "actionPerformed", cb);
|
|
302
363
|
}
|
|
@@ -312,6 +373,7 @@ exports.onAction = onAction;
|
|
|
312
373
|
exports.onNotificationReceived = onNotificationReceived;
|
|
313
374
|
exports.pending = pending;
|
|
314
375
|
exports.registerActionTypes = registerActionTypes;
|
|
376
|
+
exports.registerForPushNotifications = registerForPushNotifications;
|
|
315
377
|
exports.removeActive = removeActive;
|
|
316
378
|
exports.removeAllActive = removeAllActive;
|
|
317
379
|
exports.removeChannel = removeChannel;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { type PluginListener } from "@tauri-apps/api/core";
|
|
|
8
8
|
export type { PermissionState } from "@tauri-apps/api/core";
|
|
9
9
|
/**
|
|
10
10
|
* Options to send a notification.
|
|
11
|
-
*
|
|
12
|
-
* @since 2.0.0
|
|
13
11
|
*/
|
|
14
12
|
interface Options {
|
|
15
13
|
/**
|
|
@@ -17,10 +15,10 @@ interface Options {
|
|
|
17
15
|
*/
|
|
18
16
|
id?: number;
|
|
19
17
|
/**
|
|
20
|
-
* Identifier of the {@link Channel} that
|
|
18
|
+
* Identifier of the {@link Channel} that delivers this notification.
|
|
21
19
|
*
|
|
22
20
|
* If the channel does not exist, the notification won't fire.
|
|
23
|
-
* Make sure the channel exists with {@link
|
|
21
|
+
* Make sure the channel exists with {@link channels} and {@link createChannel}.
|
|
24
22
|
*/
|
|
25
23
|
channelId?: string;
|
|
26
24
|
/**
|
|
@@ -120,24 +118,37 @@ interface Options {
|
|
|
120
118
|
*/
|
|
121
119
|
number?: number;
|
|
122
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Interval configuration for scheduling notifications.
|
|
123
|
+
*/
|
|
123
124
|
interface ScheduleInterval {
|
|
125
|
+
/** Year component of the schedule interval. */
|
|
124
126
|
year?: number;
|
|
127
|
+
/** Month component of the schedule interval. */
|
|
125
128
|
month?: number;
|
|
129
|
+
/** Day component of the schedule interval. */
|
|
126
130
|
day?: number;
|
|
127
131
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
132
|
+
* Weekday component of the schedule interval.
|
|
133
|
+
* - 1 - Sunday
|
|
134
|
+
* - 2 - Monday
|
|
135
|
+
* - 3 - Tuesday
|
|
136
|
+
* - 4 - Wednesday
|
|
137
|
+
* - 5 - Thursday
|
|
138
|
+
* - 6 - Friday
|
|
139
|
+
* - 7 - Saturday
|
|
135
140
|
*/
|
|
136
141
|
weekday?: number;
|
|
142
|
+
/** Hour component of the schedule interval. */
|
|
137
143
|
hour?: number;
|
|
144
|
+
/** Minute component of the schedule interval. */
|
|
138
145
|
minute?: number;
|
|
146
|
+
/** Second component of the schedule interval. */
|
|
139
147
|
second?: number;
|
|
140
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Predefined intervals for repeating notifications.
|
|
151
|
+
*/
|
|
141
152
|
declare enum ScheduleEvery {
|
|
142
153
|
Year = "year",
|
|
143
154
|
Month = "month",
|
|
@@ -151,23 +162,52 @@ declare enum ScheduleEvery {
|
|
|
151
162
|
*/
|
|
152
163
|
Second = "second"
|
|
153
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Schedule configuration for notifications.
|
|
167
|
+
*/
|
|
154
168
|
declare class Schedule {
|
|
169
|
+
/** Schedule a notification at a specific date and time. */
|
|
155
170
|
at: {
|
|
156
171
|
date: Date;
|
|
157
172
|
repeating: boolean;
|
|
158
173
|
allowWhileIdle: boolean;
|
|
159
174
|
} | undefined;
|
|
175
|
+
/** Schedule a notification using an interval configuration. */
|
|
160
176
|
interval: {
|
|
161
177
|
interval: ScheduleInterval;
|
|
162
178
|
allowWhileIdle: boolean;
|
|
163
179
|
} | undefined;
|
|
180
|
+
/** Schedule a notification to repeat at regular intervals. */
|
|
164
181
|
every: {
|
|
165
182
|
interval: ScheduleEvery;
|
|
166
183
|
count: number;
|
|
167
184
|
allowWhileIdle: boolean;
|
|
168
185
|
} | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Creates a schedule to fire at a specific date and time.
|
|
188
|
+
*
|
|
189
|
+
* @param date - The date and time to fire the notification.
|
|
190
|
+
* @param repeating - Whether to repeat the notification at the same time daily.
|
|
191
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
192
|
+
* @returns A new Schedule instance.
|
|
193
|
+
*/
|
|
169
194
|
static at(date: Date, repeating?: boolean, allowWhileIdle?: boolean): Schedule;
|
|
195
|
+
/**
|
|
196
|
+
* Creates a schedule using an interval configuration.
|
|
197
|
+
*
|
|
198
|
+
* @param interval - The interval configuration specifying when to fire.
|
|
199
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
200
|
+
* @returns A new Schedule instance.
|
|
201
|
+
*/
|
|
170
202
|
static interval(interval: ScheduleInterval, allowWhileIdle?: boolean): Schedule;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a schedule to repeat at regular intervals.
|
|
205
|
+
*
|
|
206
|
+
* @param kind - The type of interval (year, month, week, day, hour, minute, second).
|
|
207
|
+
* @param count - The number of intervals between notifications.
|
|
208
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
209
|
+
* @returns A new Schedule instance.
|
|
210
|
+
*/
|
|
171
211
|
static every(kind: ScheduleEvery, count: number, allowWhileIdle?: boolean): Schedule;
|
|
172
212
|
}
|
|
173
213
|
/**
|
|
@@ -179,90 +219,151 @@ interface Attachment {
|
|
|
179
219
|
/** Attachment URL. Accepts the `asset` and `file` protocols. */
|
|
180
220
|
url: string;
|
|
181
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* An action that can be performed from a notification.
|
|
224
|
+
*/
|
|
182
225
|
interface Action {
|
|
226
|
+
/** Unique identifier for the action. */
|
|
183
227
|
id: string;
|
|
228
|
+
/** The title text displayed for the action. */
|
|
184
229
|
title: string;
|
|
230
|
+
/** Whether the action requires device authentication (iOS). */
|
|
185
231
|
requiresAuthentication?: boolean;
|
|
232
|
+
/** Whether the action should launch the app in the foreground. */
|
|
186
233
|
foreground?: boolean;
|
|
234
|
+
/** Whether the action is destructive (displayed in red on iOS). */
|
|
187
235
|
destructive?: boolean;
|
|
236
|
+
/** Whether the action allows text input. */
|
|
188
237
|
input?: boolean;
|
|
238
|
+
/** The title for the input button when `input` is true. */
|
|
189
239
|
inputButtonTitle?: string;
|
|
240
|
+
/** Placeholder text for the input field when `input` is true. */
|
|
190
241
|
inputPlaceholder?: string;
|
|
191
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* A group of related actions that can be performed from a notification.
|
|
245
|
+
*/
|
|
192
246
|
interface ActionType {
|
|
193
|
-
/**
|
|
194
|
-
* The identifier of this action type
|
|
195
|
-
*/
|
|
247
|
+
/** The identifier of this action type. */
|
|
196
248
|
id: string;
|
|
197
|
-
/**
|
|
198
|
-
* The list of associated actions
|
|
199
|
-
*/
|
|
249
|
+
/** The list of associated actions. */
|
|
200
250
|
actions: Action[];
|
|
251
|
+
/** Placeholder text shown in place of the notification body when previews are hidden (iOS). */
|
|
201
252
|
hiddenPreviewsBodyPlaceholder?: string;
|
|
253
|
+
/** Whether to include a custom dismiss action (iOS). */
|
|
202
254
|
customDismissAction?: boolean;
|
|
255
|
+
/** Whether the notification can be displayed in CarPlay (iOS). */
|
|
203
256
|
allowInCarPlay?: boolean;
|
|
257
|
+
/** Whether to show the title when previews are hidden (iOS). */
|
|
204
258
|
hiddenPreviewsShowTitle?: boolean;
|
|
259
|
+
/** Whether to show the subtitle when previews are hidden (iOS). */
|
|
205
260
|
hiddenPreviewsShowSubtitle?: boolean;
|
|
206
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Represents a scheduled notification that has not yet been delivered.
|
|
264
|
+
*/
|
|
207
265
|
interface PendingNotification {
|
|
266
|
+
/** Notification identifier. */
|
|
208
267
|
id: number;
|
|
268
|
+
/** Notification title. */
|
|
209
269
|
title?: string;
|
|
270
|
+
/** Notification body. */
|
|
210
271
|
body?: string;
|
|
272
|
+
/** The schedule configuration for this notification. */
|
|
211
273
|
schedule: Schedule;
|
|
212
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Represents a notification that is currently displayed.
|
|
277
|
+
*/
|
|
213
278
|
interface ActiveNotification {
|
|
279
|
+
/** Notification identifier. */
|
|
214
280
|
id: number;
|
|
281
|
+
/** Optional tag for the notification. */
|
|
215
282
|
tag?: string;
|
|
283
|
+
/** Notification title. */
|
|
216
284
|
title?: string;
|
|
285
|
+
/** Notification body. */
|
|
217
286
|
body?: string;
|
|
287
|
+
/** Group identifier for this notification. */
|
|
218
288
|
group?: string;
|
|
289
|
+
/** Whether this notification is a group summary. */
|
|
219
290
|
groupSummary: boolean;
|
|
291
|
+
/** Additional string data attached to the notification. */
|
|
220
292
|
data: Record<string, string>;
|
|
293
|
+
/** Extra payload stored in the notification. */
|
|
221
294
|
extra: Record<string, unknown>;
|
|
295
|
+
/** List of attachments for this notification. */
|
|
222
296
|
attachments: Attachment[];
|
|
297
|
+
/** The action type identifier for this notification. */
|
|
223
298
|
actionTypeId?: string;
|
|
299
|
+
/** The schedule configuration if this was a scheduled notification. */
|
|
224
300
|
schedule?: Schedule;
|
|
301
|
+
/** The sound resource name. */
|
|
225
302
|
sound?: string;
|
|
226
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* The importance level of a notification channel (Android).
|
|
306
|
+
*/
|
|
227
307
|
declare enum Importance {
|
|
308
|
+
/** Does not show notifications. */
|
|
228
309
|
None = 0,
|
|
310
|
+
/** Shows notifications only in the notification shade, no sound, no visual interruption. */
|
|
229
311
|
Min = 1,
|
|
312
|
+
/** Shows notifications everywhere, but is not intrusive. */
|
|
230
313
|
Low = 2,
|
|
314
|
+
/** Shows notifications everywhere with sound. */
|
|
231
315
|
Default = 3,
|
|
316
|
+
/** Shows notifications everywhere with sound and heads-up display. */
|
|
232
317
|
High = 4
|
|
233
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* The visibility of a notification on the lock screen (Android).
|
|
321
|
+
*/
|
|
234
322
|
declare enum Visibility {
|
|
323
|
+
/** Do not show any part of this notification on the lock screen. */
|
|
235
324
|
Secret = -1,
|
|
325
|
+
/** Show the notification, but hide sensitive content on the lock screen. */
|
|
236
326
|
Private = 0,
|
|
327
|
+
/** Show the entire notification on the lock screen. */
|
|
237
328
|
Public = 1
|
|
238
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* A notification channel (Android).
|
|
332
|
+
*/
|
|
239
333
|
interface Channel {
|
|
334
|
+
/** Channel identifier. */
|
|
240
335
|
id: string;
|
|
336
|
+
/** Channel name shown to the user. */
|
|
241
337
|
name: string;
|
|
338
|
+
/** Channel description shown to the user. */
|
|
242
339
|
description?: string;
|
|
340
|
+
/** Sound resource name for notifications in this channel. */
|
|
243
341
|
sound?: string;
|
|
342
|
+
/** Whether to show LED lights for notifications in this channel. */
|
|
244
343
|
lights?: boolean;
|
|
344
|
+
/** The LED light color in hex format (e.g., "#FF0000"). */
|
|
245
345
|
lightColor?: string;
|
|
346
|
+
/** Whether to vibrate for notifications in this channel. */
|
|
246
347
|
vibration?: boolean;
|
|
348
|
+
/** The importance level for notifications in this channel. */
|
|
247
349
|
importance?: Importance;
|
|
350
|
+
/** The visibility level on the lock screen for notifications in this channel. */
|
|
248
351
|
visibility?: Visibility;
|
|
249
352
|
}
|
|
250
353
|
/**
|
|
251
354
|
* Checks if the permission to send notifications is granted.
|
|
252
355
|
* @example
|
|
253
356
|
* ```typescript
|
|
254
|
-
* import { isPermissionGranted } from '@tauri-
|
|
357
|
+
* import { isPermissionGranted } from '@choochmeque/tauri-plugin-notifications-api';
|
|
255
358
|
* const permissionGranted = await isPermissionGranted();
|
|
256
359
|
* ```
|
|
257
|
-
*
|
|
258
|
-
* @since 2.0.0
|
|
259
360
|
*/
|
|
260
361
|
declare function isPermissionGranted(): Promise<boolean>;
|
|
261
362
|
/**
|
|
262
363
|
* Requests the permission to send notifications.
|
|
263
364
|
* @example
|
|
264
365
|
* ```typescript
|
|
265
|
-
* import { isPermissionGranted, requestPermission } from '@tauri-
|
|
366
|
+
* import { isPermissionGranted, requestPermission } from '@choochmeque/tauri-plugin-notifications-api';
|
|
266
367
|
* let permissionGranted = await isPermissionGranted();
|
|
267
368
|
* if (!permissionGranted) {
|
|
268
369
|
* const permission = await requestPermission();
|
|
@@ -271,15 +372,26 @@ declare function isPermissionGranted(): Promise<boolean>;
|
|
|
271
372
|
* ```
|
|
272
373
|
*
|
|
273
374
|
* @returns A promise resolving to whether the user granted the permission or not.
|
|
274
|
-
*
|
|
275
|
-
* @since 2.0.0
|
|
276
375
|
*/
|
|
277
376
|
declare function requestPermission(): Promise<NotificationPermission>;
|
|
377
|
+
/**
|
|
378
|
+
* Registers the app for push notifications (mobile).
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* import { registerForPushNotifications } from '@choochmeque/tauri-plugin-notifications-api';
|
|
383
|
+
* const token = await registerForPushNotifications();
|
|
384
|
+
* console.log('Push token:', token);
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @returns A promise resolving to the device push token.
|
|
388
|
+
*/
|
|
389
|
+
declare function registerForPushNotifications(): Promise<string>;
|
|
278
390
|
/**
|
|
279
391
|
* Sends a notification to the user.
|
|
280
392
|
* @example
|
|
281
393
|
* ```typescript
|
|
282
|
-
* import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-
|
|
394
|
+
* import { isPermissionGranted, requestPermission, sendNotification } from '@choochmeque/tauri-plugin-notifications-api';
|
|
283
395
|
* let permissionGranted = await isPermissionGranted();
|
|
284
396
|
* if (!permissionGranted) {
|
|
285
397
|
* const permission = await requestPermission();
|
|
@@ -290,8 +402,6 @@ declare function requestPermission(): Promise<NotificationPermission>;
|
|
|
290
402
|
* sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' });
|
|
291
403
|
* }
|
|
292
404
|
* ```
|
|
293
|
-
*
|
|
294
|
-
* @since 2.0.0
|
|
295
405
|
*/
|
|
296
406
|
declare function sendNotification(options: Options | string): Promise<void>;
|
|
297
407
|
/**
|
|
@@ -299,7 +409,7 @@ declare function sendNotification(options: Options | string): Promise<void>;
|
|
|
299
409
|
*
|
|
300
410
|
* @example
|
|
301
411
|
* ```typescript
|
|
302
|
-
* import { registerActionTypes } from '@tauri-
|
|
412
|
+
* import { registerActionTypes } from '@choochmeque/tauri-plugin-notifications-api';
|
|
303
413
|
* await registerActionTypes([{
|
|
304
414
|
* id: 'tauri',
|
|
305
415
|
* actions: [{
|
|
@@ -310,8 +420,6 @@ declare function sendNotification(options: Options | string): Promise<void>;
|
|
|
310
420
|
* ```
|
|
311
421
|
*
|
|
312
422
|
* @returns A promise indicating the success or failure of the operation.
|
|
313
|
-
*
|
|
314
|
-
* @since 2.0.0
|
|
315
423
|
*/
|
|
316
424
|
declare function registerActionTypes(types: ActionType[]): Promise<void>;
|
|
317
425
|
/**
|
|
@@ -319,13 +427,11 @@ declare function registerActionTypes(types: ActionType[]): Promise<void>;
|
|
|
319
427
|
*
|
|
320
428
|
* @example
|
|
321
429
|
* ```typescript
|
|
322
|
-
* import { pending } from '@tauri-
|
|
430
|
+
* import { pending } from '@choochmeque/tauri-plugin-notifications-api';
|
|
323
431
|
* const pendingNotifications = await pending();
|
|
324
432
|
* ```
|
|
325
433
|
*
|
|
326
434
|
* @returns A promise resolving to the list of pending notifications.
|
|
327
|
-
*
|
|
328
|
-
* @since 2.0.0
|
|
329
435
|
*/
|
|
330
436
|
declare function pending(): Promise<PendingNotification[]>;
|
|
331
437
|
/**
|
|
@@ -333,13 +439,11 @@ declare function pending(): Promise<PendingNotification[]>;
|
|
|
333
439
|
*
|
|
334
440
|
* @example
|
|
335
441
|
* ```typescript
|
|
336
|
-
* import { cancel } from '@tauri-
|
|
442
|
+
* import { cancel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
337
443
|
* await cancel([-34234, 23432, 4311]);
|
|
338
444
|
* ```
|
|
339
445
|
*
|
|
340
446
|
* @returns A promise indicating the success or failure of the operation.
|
|
341
|
-
*
|
|
342
|
-
* @since 2.0.0
|
|
343
447
|
*/
|
|
344
448
|
declare function cancel(notifications: number[]): Promise<void>;
|
|
345
449
|
/**
|
|
@@ -347,13 +451,11 @@ declare function cancel(notifications: number[]): Promise<void>;
|
|
|
347
451
|
*
|
|
348
452
|
* @example
|
|
349
453
|
* ```typescript
|
|
350
|
-
* import { cancelAll } from '@tauri-
|
|
454
|
+
* import { cancelAll } from '@choochmeque/tauri-plugin-notifications-api';
|
|
351
455
|
* await cancelAll();
|
|
352
456
|
* ```
|
|
353
457
|
*
|
|
354
458
|
* @returns A promise indicating the success or failure of the operation.
|
|
355
|
-
*
|
|
356
|
-
* @since 2.0.0
|
|
357
459
|
*/
|
|
358
460
|
declare function cancelAll(): Promise<void>;
|
|
359
461
|
/**
|
|
@@ -361,13 +463,11 @@ declare function cancelAll(): Promise<void>;
|
|
|
361
463
|
*
|
|
362
464
|
* @example
|
|
363
465
|
* ```typescript
|
|
364
|
-
* import { active } from '@tauri-
|
|
466
|
+
* import { active } from '@choochmeque/tauri-plugin-notifications-api';
|
|
365
467
|
* const activeNotifications = await active();
|
|
366
468
|
* ```
|
|
367
469
|
*
|
|
368
470
|
* @returns A promise resolving to the list of active notifications.
|
|
369
|
-
*
|
|
370
|
-
* @since 2.0.0
|
|
371
471
|
*/
|
|
372
472
|
declare function active(): Promise<ActiveNotification[]>;
|
|
373
473
|
/**
|
|
@@ -375,13 +475,11 @@ declare function active(): Promise<ActiveNotification[]>;
|
|
|
375
475
|
*
|
|
376
476
|
* @example
|
|
377
477
|
* ```typescript
|
|
378
|
-
* import {
|
|
379
|
-
* await
|
|
478
|
+
* import { removeActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
479
|
+
* await removeActive([{ id: 1 }, { id: 2, tag: 'news' }]);
|
|
380
480
|
* ```
|
|
381
481
|
*
|
|
382
482
|
* @returns A promise indicating the success or failure of the operation.
|
|
383
|
-
*
|
|
384
|
-
* @since 2.0.0
|
|
385
483
|
*/
|
|
386
484
|
declare function removeActive(notifications: Array<{
|
|
387
485
|
id: number;
|
|
@@ -392,13 +490,11 @@ declare function removeActive(notifications: Array<{
|
|
|
392
490
|
*
|
|
393
491
|
* @example
|
|
394
492
|
* ```typescript
|
|
395
|
-
* import { removeAllActive } from '@tauri-
|
|
493
|
+
* import { removeAllActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
396
494
|
* await removeAllActive()
|
|
397
495
|
* ```
|
|
398
496
|
*
|
|
399
497
|
* @returns A promise indicating the success or failure of the operation.
|
|
400
|
-
*
|
|
401
|
-
* @since 2.0.0
|
|
402
498
|
*/
|
|
403
499
|
declare function removeAllActive(): Promise<void>;
|
|
404
500
|
/**
|
|
@@ -406,7 +502,7 @@ declare function removeAllActive(): Promise<void>;
|
|
|
406
502
|
*
|
|
407
503
|
* @example
|
|
408
504
|
* ```typescript
|
|
409
|
-
* import { createChannel, Importance, Visibility } from '@tauri-
|
|
505
|
+
* import { createChannel, Importance, Visibility } from '@choochmeque/tauri-plugin-notifications-api';
|
|
410
506
|
* await createChannel({
|
|
411
507
|
* id: 'new-messages',
|
|
412
508
|
* name: 'New Messages',
|
|
@@ -418,8 +514,6 @@ declare function removeAllActive(): Promise<void>;
|
|
|
418
514
|
* ```
|
|
419
515
|
*
|
|
420
516
|
* @returns A promise indicating the success or failure of the operation.
|
|
421
|
-
*
|
|
422
|
-
* @since 2.0.0
|
|
423
517
|
*/
|
|
424
518
|
declare function createChannel(channel: Channel): Promise<void>;
|
|
425
519
|
/**
|
|
@@ -427,13 +521,11 @@ declare function createChannel(channel: Channel): Promise<void>;
|
|
|
427
521
|
*
|
|
428
522
|
* @example
|
|
429
523
|
* ```typescript
|
|
430
|
-
* import { removeChannel } from '@tauri-
|
|
431
|
-
* await removeChannel();
|
|
524
|
+
* import { removeChannel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
525
|
+
* await removeChannel('new-messages');
|
|
432
526
|
* ```
|
|
433
527
|
*
|
|
434
528
|
* @returns A promise indicating the success or failure of the operation.
|
|
435
|
-
*
|
|
436
|
-
* @since 2.0.0
|
|
437
529
|
*/
|
|
438
530
|
declare function removeChannel(id: string): Promise<void>;
|
|
439
531
|
/**
|
|
@@ -441,16 +533,46 @@ declare function removeChannel(id: string): Promise<void>;
|
|
|
441
533
|
*
|
|
442
534
|
* @example
|
|
443
535
|
* ```typescript
|
|
444
|
-
* import { channels } from '@tauri-
|
|
536
|
+
* import { channels } from '@choochmeque/tauri-plugin-notifications-api';
|
|
445
537
|
* const notificationChannels = await channels();
|
|
446
538
|
* ```
|
|
447
539
|
*
|
|
448
540
|
* @returns A promise resolving to the list of notification channels.
|
|
449
|
-
*
|
|
450
|
-
* @since 2.0.0
|
|
451
541
|
*/
|
|
452
542
|
declare function channels(): Promise<Channel[]>;
|
|
543
|
+
/**
|
|
544
|
+
* Registers a listener for incoming notifications.
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* import { onNotificationReceived } from '@choochmeque/tauri-plugin-notifications-api';
|
|
549
|
+
* const unlisten = await onNotificationReceived((notification) => {
|
|
550
|
+
* console.log('Notification received:', notification);
|
|
551
|
+
* });
|
|
552
|
+
* // Later, to stop listening:
|
|
553
|
+
* // unlisten();
|
|
554
|
+
* ```
|
|
555
|
+
*
|
|
556
|
+
* @param cb - Callback function to handle received notifications.
|
|
557
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
558
|
+
*/
|
|
453
559
|
declare function onNotificationReceived(cb: (notification: Options) => void): Promise<PluginListener>;
|
|
560
|
+
/**
|
|
561
|
+
* Registers a listener for notification action events.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* import { onAction } from '@choochmeque/tauri-plugin-notifications-api';
|
|
566
|
+
* const unlisten = await onAction((notification) => {
|
|
567
|
+
* console.log('Action performed on notification:', notification);
|
|
568
|
+
* });
|
|
569
|
+
* // Later, to stop listening:
|
|
570
|
+
* // unlisten();
|
|
571
|
+
* ```
|
|
572
|
+
*
|
|
573
|
+
* @param cb - Callback function to handle notification actions.
|
|
574
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
575
|
+
*/
|
|
454
576
|
declare function onAction(cb: (notification: Options) => void): Promise<PluginListener>;
|
|
455
577
|
export type { Attachment, Options, Action, ActionType, PendingNotification, ActiveNotification, Channel, ScheduleInterval, };
|
|
456
|
-
export { Importance, Visibility, sendNotification, requestPermission, isPermissionGranted, registerActionTypes, pending, cancel, cancelAll, active, removeActive, removeAllActive, createChannel, removeChannel, channels, onNotificationReceived, onAction, Schedule, ScheduleEvery, };
|
|
578
|
+
export { Importance, Visibility, sendNotification, requestPermission, isPermissionGranted, registerForPushNotifications, registerActionTypes, pending, cancel, cancelAll, active, removeActive, removeAllActive, createChannel, removeChannel, channels, onNotificationReceived, onAction, Schedule, ScheduleEvery, };
|
package/dist-js/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { invoke, addPluginListener } from '@tauri-apps/api/core';
|
|
2
2
|
|
|
3
|
-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
// SPDX-License-Identifier: MIT
|
|
6
3
|
/**
|
|
7
4
|
* Send toast notifications (brief auto-expiring OS window element) to your user.
|
|
8
5
|
* Can also be used with the Notification Web API.
|
|
9
6
|
*
|
|
10
7
|
* @module
|
|
11
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Predefined intervals for repeating notifications.
|
|
11
|
+
*/
|
|
12
12
|
var ScheduleEvery;
|
|
13
13
|
(function (ScheduleEvery) {
|
|
14
14
|
ScheduleEvery["Year"] = "year";
|
|
@@ -23,7 +23,18 @@ var ScheduleEvery;
|
|
|
23
23
|
*/
|
|
24
24
|
ScheduleEvery["Second"] = "second";
|
|
25
25
|
})(ScheduleEvery || (ScheduleEvery = {}));
|
|
26
|
+
/**
|
|
27
|
+
* Schedule configuration for notifications.
|
|
28
|
+
*/
|
|
26
29
|
class Schedule {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a schedule to fire at a specific date and time.
|
|
32
|
+
*
|
|
33
|
+
* @param date - The date and time to fire the notification.
|
|
34
|
+
* @param repeating - Whether to repeat the notification at the same time daily.
|
|
35
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
36
|
+
* @returns A new Schedule instance.
|
|
37
|
+
*/
|
|
27
38
|
static at(date, repeating = false, allowWhileIdle = false) {
|
|
28
39
|
return {
|
|
29
40
|
at: { date, repeating, allowWhileIdle },
|
|
@@ -31,6 +42,13 @@ class Schedule {
|
|
|
31
42
|
every: undefined,
|
|
32
43
|
};
|
|
33
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a schedule using an interval configuration.
|
|
47
|
+
*
|
|
48
|
+
* @param interval - The interval configuration specifying when to fire.
|
|
49
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
50
|
+
* @returns A new Schedule instance.
|
|
51
|
+
*/
|
|
34
52
|
static interval(interval, allowWhileIdle = false) {
|
|
35
53
|
return {
|
|
36
54
|
at: undefined,
|
|
@@ -38,6 +56,14 @@ class Schedule {
|
|
|
38
56
|
every: undefined,
|
|
39
57
|
};
|
|
40
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a schedule to repeat at regular intervals.
|
|
61
|
+
*
|
|
62
|
+
* @param kind - The type of interval (year, month, week, day, hour, minute, second).
|
|
63
|
+
* @param count - The number of intervals between notifications.
|
|
64
|
+
* @param allowWhileIdle - On Android, allows notification to fire even when the device is in idle mode.
|
|
65
|
+
* @returns A new Schedule instance.
|
|
66
|
+
*/
|
|
41
67
|
static every(kind, count, allowWhileIdle = false) {
|
|
42
68
|
return {
|
|
43
69
|
at: undefined,
|
|
@@ -46,29 +72,41 @@ class Schedule {
|
|
|
46
72
|
};
|
|
47
73
|
}
|
|
48
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The importance level of a notification channel (Android).
|
|
77
|
+
*/
|
|
49
78
|
var Importance;
|
|
50
79
|
(function (Importance) {
|
|
80
|
+
/** Does not show notifications. */
|
|
51
81
|
Importance[Importance["None"] = 0] = "None";
|
|
82
|
+
/** Shows notifications only in the notification shade, no sound, no visual interruption. */
|
|
52
83
|
Importance[Importance["Min"] = 1] = "Min";
|
|
84
|
+
/** Shows notifications everywhere, but is not intrusive. */
|
|
53
85
|
Importance[Importance["Low"] = 2] = "Low";
|
|
86
|
+
/** Shows notifications everywhere with sound. */
|
|
54
87
|
Importance[Importance["Default"] = 3] = "Default";
|
|
88
|
+
/** Shows notifications everywhere with sound and heads-up display. */
|
|
55
89
|
Importance[Importance["High"] = 4] = "High";
|
|
56
90
|
})(Importance || (Importance = {}));
|
|
91
|
+
/**
|
|
92
|
+
* The visibility of a notification on the lock screen (Android).
|
|
93
|
+
*/
|
|
57
94
|
var Visibility;
|
|
58
95
|
(function (Visibility) {
|
|
96
|
+
/** Do not show any part of this notification on the lock screen. */
|
|
59
97
|
Visibility[Visibility["Secret"] = -1] = "Secret";
|
|
98
|
+
/** Show the notification, but hide sensitive content on the lock screen. */
|
|
60
99
|
Visibility[Visibility["Private"] = 0] = "Private";
|
|
100
|
+
/** Show the entire notification on the lock screen. */
|
|
61
101
|
Visibility[Visibility["Public"] = 1] = "Public";
|
|
62
102
|
})(Visibility || (Visibility = {}));
|
|
63
103
|
/**
|
|
64
104
|
* Checks if the permission to send notifications is granted.
|
|
65
105
|
* @example
|
|
66
106
|
* ```typescript
|
|
67
|
-
* import { isPermissionGranted } from '@tauri-
|
|
107
|
+
* import { isPermissionGranted } from '@choochmeque/tauri-plugin-notifications-api';
|
|
68
108
|
* const permissionGranted = await isPermissionGranted();
|
|
69
109
|
* ```
|
|
70
|
-
*
|
|
71
|
-
* @since 2.0.0
|
|
72
110
|
*/
|
|
73
111
|
async function isPermissionGranted() {
|
|
74
112
|
return await invoke("plugin:notifications|is_permission_granted");
|
|
@@ -77,7 +115,7 @@ async function isPermissionGranted() {
|
|
|
77
115
|
* Requests the permission to send notifications.
|
|
78
116
|
* @example
|
|
79
117
|
* ```typescript
|
|
80
|
-
* import { isPermissionGranted, requestPermission } from '@tauri-
|
|
118
|
+
* import { isPermissionGranted, requestPermission } from '@choochmeque/tauri-plugin-notifications-api';
|
|
81
119
|
* let permissionGranted = await isPermissionGranted();
|
|
82
120
|
* if (!permissionGranted) {
|
|
83
121
|
* const permission = await requestPermission();
|
|
@@ -86,17 +124,30 @@ async function isPermissionGranted() {
|
|
|
86
124
|
* ```
|
|
87
125
|
*
|
|
88
126
|
* @returns A promise resolving to whether the user granted the permission or not.
|
|
89
|
-
*
|
|
90
|
-
* @since 2.0.0
|
|
91
127
|
*/
|
|
92
128
|
async function requestPermission() {
|
|
93
129
|
return await invoke("plugin:notifications|request_permission");
|
|
94
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Registers the app for push notifications (mobile).
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import { registerForPushNotifications } from '@choochmeque/tauri-plugin-notifications-api';
|
|
137
|
+
* const token = await registerForPushNotifications();
|
|
138
|
+
* console.log('Push token:', token);
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @returns A promise resolving to the device push token.
|
|
142
|
+
*/
|
|
143
|
+
async function registerForPushNotifications() {
|
|
144
|
+
return await invoke("plugin:notifications|register_for_push_notifications");
|
|
145
|
+
}
|
|
95
146
|
/**
|
|
96
147
|
* Sends a notification to the user.
|
|
97
148
|
* @example
|
|
98
149
|
* ```typescript
|
|
99
|
-
* import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-
|
|
150
|
+
* import { isPermissionGranted, requestPermission, sendNotification } from '@choochmeque/tauri-plugin-notifications-api';
|
|
100
151
|
* let permissionGranted = await isPermissionGranted();
|
|
101
152
|
* if (!permissionGranted) {
|
|
102
153
|
* const permission = await requestPermission();
|
|
@@ -107,8 +158,6 @@ async function requestPermission() {
|
|
|
107
158
|
* sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' });
|
|
108
159
|
* }
|
|
109
160
|
* ```
|
|
110
|
-
*
|
|
111
|
-
* @since 2.0.0
|
|
112
161
|
*/
|
|
113
162
|
async function sendNotification(options) {
|
|
114
163
|
await invoke("plugin:notifications|notify", {
|
|
@@ -124,7 +173,7 @@ async function sendNotification(options) {
|
|
|
124
173
|
*
|
|
125
174
|
* @example
|
|
126
175
|
* ```typescript
|
|
127
|
-
* import { registerActionTypes } from '@tauri-
|
|
176
|
+
* import { registerActionTypes } from '@choochmeque/tauri-plugin-notifications-api';
|
|
128
177
|
* await registerActionTypes([{
|
|
129
178
|
* id: 'tauri',
|
|
130
179
|
* actions: [{
|
|
@@ -135,8 +184,6 @@ async function sendNotification(options) {
|
|
|
135
184
|
* ```
|
|
136
185
|
*
|
|
137
186
|
* @returns A promise indicating the success or failure of the operation.
|
|
138
|
-
*
|
|
139
|
-
* @since 2.0.0
|
|
140
187
|
*/
|
|
141
188
|
async function registerActionTypes(types) {
|
|
142
189
|
await invoke("plugin:notifications|register_action_types", { types });
|
|
@@ -146,13 +193,11 @@ async function registerActionTypes(types) {
|
|
|
146
193
|
*
|
|
147
194
|
* @example
|
|
148
195
|
* ```typescript
|
|
149
|
-
* import { pending } from '@tauri-
|
|
196
|
+
* import { pending } from '@choochmeque/tauri-plugin-notifications-api';
|
|
150
197
|
* const pendingNotifications = await pending();
|
|
151
198
|
* ```
|
|
152
199
|
*
|
|
153
200
|
* @returns A promise resolving to the list of pending notifications.
|
|
154
|
-
*
|
|
155
|
-
* @since 2.0.0
|
|
156
201
|
*/
|
|
157
202
|
async function pending() {
|
|
158
203
|
return await invoke("plugin:notifications|get_pending");
|
|
@@ -162,13 +207,11 @@ async function pending() {
|
|
|
162
207
|
*
|
|
163
208
|
* @example
|
|
164
209
|
* ```typescript
|
|
165
|
-
* import { cancel } from '@tauri-
|
|
210
|
+
* import { cancel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
166
211
|
* await cancel([-34234, 23432, 4311]);
|
|
167
212
|
* ```
|
|
168
213
|
*
|
|
169
214
|
* @returns A promise indicating the success or failure of the operation.
|
|
170
|
-
*
|
|
171
|
-
* @since 2.0.0
|
|
172
215
|
*/
|
|
173
216
|
async function cancel(notifications) {
|
|
174
217
|
await invoke("plugin:notifications|cancel", { notifications });
|
|
@@ -178,13 +221,11 @@ async function cancel(notifications) {
|
|
|
178
221
|
*
|
|
179
222
|
* @example
|
|
180
223
|
* ```typescript
|
|
181
|
-
* import { cancelAll } from '@tauri-
|
|
224
|
+
* import { cancelAll } from '@choochmeque/tauri-plugin-notifications-api';
|
|
182
225
|
* await cancelAll();
|
|
183
226
|
* ```
|
|
184
227
|
*
|
|
185
228
|
* @returns A promise indicating the success or failure of the operation.
|
|
186
|
-
*
|
|
187
|
-
* @since 2.0.0
|
|
188
229
|
*/
|
|
189
230
|
async function cancelAll() {
|
|
190
231
|
await invoke("plugin:notifications|cancel");
|
|
@@ -194,13 +235,11 @@ async function cancelAll() {
|
|
|
194
235
|
*
|
|
195
236
|
* @example
|
|
196
237
|
* ```typescript
|
|
197
|
-
* import { active } from '@tauri-
|
|
238
|
+
* import { active } from '@choochmeque/tauri-plugin-notifications-api';
|
|
198
239
|
* const activeNotifications = await active();
|
|
199
240
|
* ```
|
|
200
241
|
*
|
|
201
242
|
* @returns A promise resolving to the list of active notifications.
|
|
202
|
-
*
|
|
203
|
-
* @since 2.0.0
|
|
204
243
|
*/
|
|
205
244
|
async function active() {
|
|
206
245
|
return await invoke("plugin:notifications|get_active");
|
|
@@ -210,13 +249,11 @@ async function active() {
|
|
|
210
249
|
*
|
|
211
250
|
* @example
|
|
212
251
|
* ```typescript
|
|
213
|
-
* import {
|
|
214
|
-
* await
|
|
252
|
+
* import { removeActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
253
|
+
* await removeActive([{ id: 1 }, { id: 2, tag: 'news' }]);
|
|
215
254
|
* ```
|
|
216
255
|
*
|
|
217
256
|
* @returns A promise indicating the success or failure of the operation.
|
|
218
|
-
*
|
|
219
|
-
* @since 2.0.0
|
|
220
257
|
*/
|
|
221
258
|
async function removeActive(notifications) {
|
|
222
259
|
await invoke("plugin:notifications|remove_active", { notifications });
|
|
@@ -226,13 +263,11 @@ async function removeActive(notifications) {
|
|
|
226
263
|
*
|
|
227
264
|
* @example
|
|
228
265
|
* ```typescript
|
|
229
|
-
* import { removeAllActive } from '@tauri-
|
|
266
|
+
* import { removeAllActive } from '@choochmeque/tauri-plugin-notifications-api';
|
|
230
267
|
* await removeAllActive()
|
|
231
268
|
* ```
|
|
232
269
|
*
|
|
233
270
|
* @returns A promise indicating the success or failure of the operation.
|
|
234
|
-
*
|
|
235
|
-
* @since 2.0.0
|
|
236
271
|
*/
|
|
237
272
|
async function removeAllActive() {
|
|
238
273
|
await invoke("plugin:notifications|remove_active");
|
|
@@ -242,7 +277,7 @@ async function removeAllActive() {
|
|
|
242
277
|
*
|
|
243
278
|
* @example
|
|
244
279
|
* ```typescript
|
|
245
|
-
* import { createChannel, Importance, Visibility } from '@tauri-
|
|
280
|
+
* import { createChannel, Importance, Visibility } from '@choochmeque/tauri-plugin-notifications-api';
|
|
246
281
|
* await createChannel({
|
|
247
282
|
* id: 'new-messages',
|
|
248
283
|
* name: 'New Messages',
|
|
@@ -254,8 +289,6 @@ async function removeAllActive() {
|
|
|
254
289
|
* ```
|
|
255
290
|
*
|
|
256
291
|
* @returns A promise indicating the success or failure of the operation.
|
|
257
|
-
*
|
|
258
|
-
* @since 2.0.0
|
|
259
292
|
*/
|
|
260
293
|
async function createChannel(channel) {
|
|
261
294
|
await invoke("plugin:notifications|create_channel", { ...channel });
|
|
@@ -265,13 +298,11 @@ async function createChannel(channel) {
|
|
|
265
298
|
*
|
|
266
299
|
* @example
|
|
267
300
|
* ```typescript
|
|
268
|
-
* import { removeChannel } from '@tauri-
|
|
269
|
-
* await removeChannel();
|
|
301
|
+
* import { removeChannel } from '@choochmeque/tauri-plugin-notifications-api';
|
|
302
|
+
* await removeChannel('new-messages');
|
|
270
303
|
* ```
|
|
271
304
|
*
|
|
272
305
|
* @returns A promise indicating the success or failure of the operation.
|
|
273
|
-
*
|
|
274
|
-
* @since 2.0.0
|
|
275
306
|
*/
|
|
276
307
|
async function removeChannel(id) {
|
|
277
308
|
await invoke("plugin:notifications|delete_channel", { id });
|
|
@@ -281,22 +312,52 @@ async function removeChannel(id) {
|
|
|
281
312
|
*
|
|
282
313
|
* @example
|
|
283
314
|
* ```typescript
|
|
284
|
-
* import { channels } from '@tauri-
|
|
315
|
+
* import { channels } from '@choochmeque/tauri-plugin-notifications-api';
|
|
285
316
|
* const notificationChannels = await channels();
|
|
286
317
|
* ```
|
|
287
318
|
*
|
|
288
319
|
* @returns A promise resolving to the list of notification channels.
|
|
289
|
-
*
|
|
290
|
-
* @since 2.0.0
|
|
291
320
|
*/
|
|
292
321
|
async function channels() {
|
|
293
322
|
return await invoke("plugin:notifications|listChannels");
|
|
294
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Registers a listener for incoming notifications.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* import { onNotificationReceived } from '@choochmeque/tauri-plugin-notifications-api';
|
|
330
|
+
* const unlisten = await onNotificationReceived((notification) => {
|
|
331
|
+
* console.log('Notification received:', notification);
|
|
332
|
+
* });
|
|
333
|
+
* // Later, to stop listening:
|
|
334
|
+
* // unlisten();
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @param cb - Callback function to handle received notifications.
|
|
338
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
339
|
+
*/
|
|
295
340
|
async function onNotificationReceived(cb) {
|
|
296
341
|
return await addPluginListener("notifications", "notification", cb);
|
|
297
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Registers a listener for notification action events.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* import { onAction } from '@choochmeque/tauri-plugin-notifications-api';
|
|
349
|
+
* const unlisten = await onAction((notification) => {
|
|
350
|
+
* console.log('Action performed on notification:', notification);
|
|
351
|
+
* });
|
|
352
|
+
* // Later, to stop listening:
|
|
353
|
+
* // unlisten();
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* @param cb - Callback function to handle notification actions.
|
|
357
|
+
* @returns A promise resolving to a function that removes the listener.
|
|
358
|
+
*/
|
|
298
359
|
async function onAction(cb) {
|
|
299
360
|
return await addPluginListener("notifications", "actionPerformed", cb);
|
|
300
361
|
}
|
|
301
362
|
|
|
302
|
-
export { Importance, Schedule, ScheduleEvery, Visibility, active, cancel, cancelAll, channels, createChannel, isPermissionGranted, onAction, onNotificationReceived, pending, registerActionTypes, removeActive, removeAllActive, removeChannel, requestPermission, sendNotification };
|
|
363
|
+
export { Importance, Schedule, ScheduleEvery, Visibility, active, cancel, cancelAll, channels, createChannel, isPermissionGranted, onAction, onNotificationReceived, pending, registerActionTypes, registerForPushNotifications, removeActive, removeAllActive, removeChannel, requestPermission, sendNotification };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choochmeque/tauri-plugin-notifications-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "You",
|
|
6
|
-
"description": "A Tauri v2 plugin for sending
|
|
6
|
+
"description": "A Tauri v2 plugin for sending notifications on desktop and mobile platforms with support for system notifications and push delivery via FCM and APNs.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist-js/index.d.ts",
|
|
9
9
|
"main": "./dist-js/index.cjs",
|