@capacitor/local-notifications 1.1.0 → 4.0.0-nightly-44c040f.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/CHANGELOG.md +50 -0
- package/CapacitorLocalNotifications.podspec +1 -1
- package/README.md +100 -22
- package/android/build.gradle +10 -11
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationManager.java +48 -32
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationRestoreReceiver.java +2 -1
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationSchedule.java +2 -1
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationsPlugin.java +79 -0
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/NotificationChannelManager.java +2 -6
- package/android/src/main/java/com/capacitorjs/plugins/localnotifications/TimedNotificationPublisher.java +6 -1
- package/android/src/main/res/drawable/ic_transparent.xml +12 -0
- package/dist/docs.json +246 -22
- package/dist/esm/definitions.d.ts +128 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -1
- package/dist/esm/web.js +33 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +33 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/LocalNotificationsPlugin.m +4 -1
- package/ios/Plugin/LocalNotificationsPlugin.swift +40 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,56 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 4.0.0-beta.0 (2022-06-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **local-notifications:** Add FLAG_MUTABLE to pending intents for SDK 31 support ([#914](https://github.com/ionic-team/capacitor-plugins/issues/914)) ([9ad0ce6](https://github.com/ionic-team/capacitor-plugins/commit/9ad0ce6f1497f425db907908be1b125e6ed83dbc))
|
|
12
|
+
* **local-notifications:** Handle case of not allowed exact notifications ([#954](https://github.com/ionic-team/capacitor-plugins/issues/954)) ([5016996](https://github.com/ionic-team/capacitor-plugins/commit/5016996b3a4e9824d8dd2bc4c71892fc5dbc7365))
|
|
13
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
14
|
+
* inline source code in esm map files ([#760](https://github.com/ionic-team/capacitor-plugins/issues/760)) ([a960489](https://github.com/ionic-team/capacitor-plugins/commit/a960489a19db0182b90d187a50deff9dfbe51038))
|
|
15
|
+
* Make removeAllListeners return a promise ([#895](https://github.com/ionic-team/capacitor-plugins/issues/895)) ([e5c49d6](https://github.com/ionic-team/capacitor-plugins/commit/e5c49d64445dca70286334e6a0441d8021197b13))
|
|
16
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
17
|
+
* **android:** fire localNotificationReceived event on Android ([#217](https://github.com/ionic-team/capacitor-plugins/issues/217)) ([d97682d](https://github.com/ionic-team/capacitor-plugins/commit/d97682d9f3d6f612993716c3bc35d3015c4e0c07))
|
|
18
|
+
* **local-notification:** Throw unavailable if Notification API not supported ([#285](https://github.com/ionic-team/capacitor-plugins/issues/285)) ([a90a88b](https://github.com/ionic-team/capacitor-plugins/commit/a90a88b217f5fa2a257416050afb476dd84d8051))
|
|
19
|
+
* **local-notifications:** Adding check for `new Notification` support ([#295](https://github.com/ionic-team/capacitor-plugins/issues/295)) ([a806f22](https://github.com/ionic-team/capacitor-plugins/commit/a806f22577209322bdc93ef7fe5490d3b0b6e42f))
|
|
20
|
+
* **local-notifications:** Checking for null schedule in notification JSObject ([#258](https://github.com/ionic-team/capacitor-plugins/issues/258)) ([73cb416](https://github.com/ionic-team/capacitor-plugins/commit/73cb4168329622bb5a6625c900090a01fc5eca99))
|
|
21
|
+
* **local-notifications:** don't store notifications if not scheduled ([#310](https://github.com/ionic-team/capacitor-plugins/issues/310)) ([c1445fd](https://github.com/ionic-team/capacitor-plugins/commit/c1445fddc69db27506f83b3ea56d8e90d4384346))
|
|
22
|
+
* **local-notifications:** extra not being returned on notification events ([#340](https://github.com/ionic-team/capacitor-plugins/issues/340)) ([5b03a7f](https://github.com/ionic-team/capacitor-plugins/commit/5b03a7fdbfd2e8293a9fc3726185b516d7efa9a9))
|
|
23
|
+
* **local-notifications:** Make getPending not return already fired notifications ([#256](https://github.com/ionic-team/capacitor-plugins/issues/256)) ([fb96f8a](https://github.com/ionic-team/capacitor-plugins/commit/fb96f8ab8c4776528e5825be6c2e19567462eef8))
|
|
24
|
+
* **local-notifications:** Opt out of Capacitor date serialization ([#264](https://github.com/ionic-team/capacitor-plugins/issues/264)) ([6e447d5](https://github.com/ionic-team/capacitor-plugins/commit/6e447d54aff3cac47df540addf2a0bf05238c158))
|
|
25
|
+
* **local-notifications:** requestPermissions and checkPermissions return if enabled ([#494](https://github.com/ionic-team/capacitor-plugins/issues/494)) ([555bb1f](https://github.com/ionic-team/capacitor-plugins/commit/555bb1f9bd02ccd999891a316e7ee0f8c1844e92))
|
|
26
|
+
* **local-notifications:** return schedule on as object ([#603](https://github.com/ionic-team/capacitor-plugins/issues/603)) ([ca34b01](https://github.com/ionic-team/capacitor-plugins/commit/ca34b01c73f14bb0ad14e8a501210e42a0e65b04))
|
|
27
|
+
* **local-notifications:** Throw errors if missing mandatory channel fields ([#577](https://github.com/ionic-team/capacitor-plugins/issues/577)) ([6bf3a4f](https://github.com/ionic-team/capacitor-plugins/commit/6bf3a4f0de8880588200ae60e73427fa6959ea20))
|
|
28
|
+
* **local-notifications:** use proper rollup config ([#528](https://github.com/ionic-team/capacitor-plugins/issues/528)) ([cd17daa](https://github.com/ionic-team/capacitor-plugins/commit/cd17daa02241f50299232212ad72722d8a35ee16))
|
|
29
|
+
* normalize use of integers for notification IDs ([#195](https://github.com/ionic-team/capacitor-plugins/issues/195)) ([b56e111](https://github.com/ionic-team/capacitor-plugins/commit/b56e1118227ee58d1872dbb32a18b8484290d3c7))
|
|
30
|
+
* **web:** fix scheduled notifications not being sent ([#220](https://github.com/ionic-team/capacitor-plugins/issues/220)) ([c8e92d6](https://github.com/ionic-team/capacitor-plugins/commit/c8e92d6a178f8b3278b1d3a9c364eb8120d28848))
|
|
31
|
+
* add es2017 lib to tsconfig ([#180](https://github.com/ionic-team/capacitor-plugins/issues/180)) ([2c3776c](https://github.com/ionic-team/capacitor-plugins/commit/2c3776c38ca025c5ee965dec10ccf1cdb6c02e2f))
|
|
32
|
+
* Use the event names from Capacitor 2 ([#215](https://github.com/ionic-team/capacitor-plugins/issues/215)) ([008fe9e](https://github.com/ionic-team/capacitor-plugins/commit/008fe9e9bf6a960b0ab7b6fc4d5014f10ba13df8))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* set targetSDK default value to 31 ([#824](https://github.com/ionic-team/capacitor-plugins/issues/824)) ([3ee10de](https://github.com/ionic-team/capacitor-plugins/commit/3ee10de98067984c1a4e75295d001c5a895c47f4))
|
|
38
|
+
* set targetSDK default value to 32 ([#970](https://github.com/ionic-team/capacitor-plugins/issues/970)) ([fa70d96](https://github.com/ionic-team/capacitor-plugins/commit/fa70d96f141af751aae53ceb5642c46b204f5958))
|
|
39
|
+
* Upgrade gradle to 7.4 ([#826](https://github.com/ionic-team/capacitor-plugins/issues/826)) ([5db0906](https://github.com/ionic-team/capacitor-plugins/commit/5db0906f6264287c4f8e69dbaecf19d4d387824b))
|
|
40
|
+
* Use java 11 ([#910](https://github.com/ionic-team/capacitor-plugins/issues/910)) ([5acb2a2](https://github.com/ionic-team/capacitor-plugins/commit/5acb2a288a413492b163e4e97da46a085d9e4be0))
|
|
41
|
+
* **android:** implements Activity Result API changes for permissions and activity results ([#222](https://github.com/ionic-team/capacitor-plugins/issues/222)) ([f671b9f](https://github.com/ionic-team/capacitor-plugins/commit/f671b9f4b472806ef43db6dcf302d4503cf1828c))
|
|
42
|
+
* **local-notifications:** add more info to pending notifications ([#211](https://github.com/ionic-team/capacitor-plugins/issues/211)) ([7c50487](https://github.com/ionic-team/capacitor-plugins/commit/7c50487d40836380a27bd4c8d3655d83e0c3a720))
|
|
43
|
+
* **local-notifications:** Add weekday scheduling support for Android and iOS ([#756](https://github.com/ionic-team/capacitor-plugins/issues/756)) ([430b485](https://github.com/ionic-team/capacitor-plugins/commit/430b48592ce59ccc967dd9a081873d7dc3937e93))
|
|
44
|
+
* **local-notifications:** Adding summary text to grouped notifications ([#296](https://github.com/ionic-team/capacitor-plugins/issues/296)) ([f625bd2](https://github.com/ionic-team/capacitor-plugins/commit/f625bd28bc00dbd0b51d7bdecf5e6f3077dcc7a9))
|
|
45
|
+
* **local-notifications:** Fire local notifications while app is idle ([#237](https://github.com/ionic-team/capacitor-plugins/issues/237)) ([43380ef](https://github.com/ionic-team/capacitor-plugins/commit/43380efa8901adf9d669d0c1ef20038a2fd7df8e))
|
|
46
|
+
* **local-notifications:** Support for Big Text and Inbox Notification Style ([#280](https://github.com/ionic-team/capacitor-plugins/issues/280)) ([dc96ef9](https://github.com/ionic-team/capacitor-plugins/commit/dc96ef923725f5b53346431d35f82d5ff13f4e17))
|
|
47
|
+
* **local-notifications:** Support setting seconds in Schedule "on" ([#253](https://github.com/ionic-team/capacitor-plugins/issues/253)) ([4ec8d06](https://github.com/ionic-team/capacitor-plugins/commit/4ec8d06e0cb52403e541a05e5c3518d4c5ea754e))
|
|
48
|
+
* **web:** implement ActionPerformed and Received events ([#219](https://github.com/ionic-team/capacitor-plugins/issues/219)) ([e062901](https://github.com/ionic-team/capacitor-plugins/commit/e062901fc2e55cf6b6dc1ab20258d80a0be8b2d9))
|
|
49
|
+
* add commonjs output format ([#179](https://github.com/ionic-team/capacitor-plugins/issues/179)) ([8e9e098](https://github.com/ionic-team/capacitor-plugins/commit/8e9e09862064b3f6771d7facbc4008e995d9b463))
|
|
50
|
+
* Local Notifications plugin ([#94](https://github.com/ionic-team/capacitor-plugins/issues/94)) ([e59ba9c](https://github.com/ionic-team/capacitor-plugins/commit/e59ba9ceea78a26ec60e521825f228baa9d74577))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
6
56
|
# [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/local-notifications@1.0.10...@capacitor/local-notifications@1.1.0) (2022-01-19)
|
|
7
57
|
|
|
8
58
|
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}', 'local-notifications/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -9,6 +9,16 @@ npm install @capacitor/local-notifications
|
|
|
9
9
|
npx cap sync
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Android
|
|
13
|
+
|
|
14
|
+
Starting on Android 12, scheduled notifications won't be exact unless this permission is added to your `AndroidManifest.xml`:
|
|
15
|
+
|
|
16
|
+
```xml
|
|
17
|
+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Note that even if the permission is present, users can still disable exact notifications from the app settings.
|
|
21
|
+
|
|
12
22
|
## Configuration
|
|
13
23
|
|
|
14
24
|
<docgen-config>
|
|
@@ -73,6 +83,9 @@ If the device has entered [Doze](https://developer.android.com/training/monitori
|
|
|
73
83
|
* [`registerActionTypes(...)`](#registeractiontypes)
|
|
74
84
|
* [`cancel(...)`](#cancel)
|
|
75
85
|
* [`areEnabled()`](#areenabled)
|
|
86
|
+
* [`getDeliveredNotifications()`](#getdeliverednotifications)
|
|
87
|
+
* [`removeDeliveredNotifications(...)`](#removedeliverednotifications)
|
|
88
|
+
* [`removeAllDeliveredNotifications()`](#removealldeliverednotifications)
|
|
76
89
|
* [`createChannel(...)`](#createchannel)
|
|
77
90
|
* [`deleteChannel(...)`](#deletechannel)
|
|
78
91
|
* [`listChannels()`](#listchannels)
|
|
@@ -175,10 +188,55 @@ Check if notifications are enabled or not.
|
|
|
175
188
|
--------------------
|
|
176
189
|
|
|
177
190
|
|
|
191
|
+
### getDeliveredNotifications()
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
getDeliveredNotifications() => Promise<DeliveredNotifications>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Get a list of notifications that are visible on the notifications screen.
|
|
198
|
+
|
|
199
|
+
**Returns:** <code>Promise<<a href="#deliverednotifications">DeliveredNotifications</a>></code>
|
|
200
|
+
|
|
201
|
+
**Since:** 4.0.0
|
|
202
|
+
|
|
203
|
+
--------------------
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### removeDeliveredNotifications(...)
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
removeDeliveredNotifications(delivered: DeliveredNotifications) => Promise<void>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Remove the specified notifications from the notifications screen.
|
|
213
|
+
|
|
214
|
+
| Param | Type |
|
|
215
|
+
| --------------- | ------------------------------------------------------------------------- |
|
|
216
|
+
| **`delivered`** | <code><a href="#deliverednotifications">DeliveredNotifications</a></code> |
|
|
217
|
+
|
|
218
|
+
**Since:** 4.0.0
|
|
219
|
+
|
|
220
|
+
--------------------
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
### removeAllDeliveredNotifications()
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
removeAllDeliveredNotifications() => Promise<void>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Remove all the notifications from the notifications screen.
|
|
230
|
+
|
|
231
|
+
**Since:** 4.0.0
|
|
232
|
+
|
|
233
|
+
--------------------
|
|
234
|
+
|
|
235
|
+
|
|
178
236
|
### createChannel(...)
|
|
179
237
|
|
|
180
238
|
```typescript
|
|
181
|
-
createChannel(channel:
|
|
239
|
+
createChannel(channel: Channel) => Promise<void>
|
|
182
240
|
```
|
|
183
241
|
|
|
184
242
|
Create a notification channel.
|
|
@@ -197,16 +255,16 @@ Only available for Android.
|
|
|
197
255
|
### deleteChannel(...)
|
|
198
256
|
|
|
199
257
|
```typescript
|
|
200
|
-
deleteChannel(
|
|
258
|
+
deleteChannel(args: { id: string; }) => Promise<void>
|
|
201
259
|
```
|
|
202
260
|
|
|
203
261
|
Delete a notification channel.
|
|
204
262
|
|
|
205
263
|
Only available for Android.
|
|
206
264
|
|
|
207
|
-
| Param
|
|
208
|
-
|
|
|
209
|
-
| **`
|
|
265
|
+
| Param | Type |
|
|
266
|
+
| ---------- | ---------------------------- |
|
|
267
|
+
| **`args`** | <code>{ id: string; }</code> |
|
|
210
268
|
|
|
211
269
|
**Since:** 1.0.0
|
|
212
270
|
|
|
@@ -357,7 +415,7 @@ The object that describes a local notification.
|
|
|
357
415
|
| **`actionTypeId`** | <code>string</code> | Associate an action type with this notification. | 1.0.0 |
|
|
358
416
|
| **`extra`** | <code>any</code> | Set extra data to store within this notification. | 1.0.0 |
|
|
359
417
|
| **`threadIdentifier`** | <code>string</code> | Used to group multiple notifications. Sets `threadIdentifier` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
|
|
360
|
-
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Sets `summaryArgument` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS
|
|
418
|
+
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Sets `summaryArgument` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
|
|
361
419
|
| **`group`** | <code>string</code> | Used to group multiple notifications. Calls `setGroup()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android. | 1.0.0 |
|
|
362
420
|
| **`groupSummary`** | <code>boolean</code> | If true, this notification becomes the summary for a group of notifications. Calls `setGroupSummary()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android when using `group`. | 1.0.0 |
|
|
363
421
|
| **`channelId`** | <code>string</code> | Specifies the channel the notification should be delivered on. If channel with the given name does not exist then the notification will not fire. If not provided, it will use the default channel. Calls `setChannelId()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android 26+. | 1.0.0 |
|
|
@@ -537,19 +595,44 @@ An action that can be taken when a notification is displayed.
|
|
|
537
595
|
| **`value`** | <code>boolean</code> | Whether or not the device has local notifications enabled. | 1.0.0 |
|
|
538
596
|
|
|
539
597
|
|
|
598
|
+
#### DeliveredNotifications
|
|
599
|
+
|
|
600
|
+
| Prop | Type | Description | Since |
|
|
601
|
+
| ------------------- | ------------------------------------------ | ------------------------------------------------------------------- | ----- |
|
|
602
|
+
| **`notifications`** | <code>DeliveredNotificationSchema[]</code> | List of notifications that are visible on the notifications screen. | 1.0.0 |
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
#### DeliveredNotificationSchema
|
|
606
|
+
|
|
607
|
+
| Prop | Type | Description | Since |
|
|
608
|
+
| ------------------ | --------------------------------------------- | ---------------------------------------------------------------------------------------------- | ----- |
|
|
609
|
+
| **`id`** | <code>number</code> | The notification identifier. | 4.0.0 |
|
|
610
|
+
| **`tag`** | <code>string</code> | The notification tag. Only available on Android. | 4.0.0 |
|
|
611
|
+
| **`title`** | <code>string</code> | The title of the notification. | 4.0.0 |
|
|
612
|
+
| **`body`** | <code>string</code> | The body of the notification, shown below the title. | 4.0.0 |
|
|
613
|
+
| **`group`** | <code>string</code> | The configured group of the notification. Only available for Android. | 4.0.0 |
|
|
614
|
+
| **`groupSummary`** | <code>boolean</code> | If this notification is the summary for a group of notifications. Only available for Android. | 4.0.0 |
|
|
615
|
+
| **`data`** | <code>any</code> | Any additional data that was included in the notification payload. Only available for Android. | 4.0.0 |
|
|
616
|
+
| **`extra`** | <code>any</code> | Extra data to store within this notification. Only available for iOS. | 4.0.0 |
|
|
617
|
+
| **`attachments`** | <code>Attachment[]</code> | The attachments for this notification. Only available for iOS. | 1.0.0 |
|
|
618
|
+
| **`actionTypeId`** | <code>string</code> | <a href="#action">Action</a> type ssociated with this notification. Only available for iOS. | 4.0.0 |
|
|
619
|
+
| **`schedule`** | <code><a href="#schedule">Schedule</a></code> | <a href="#schedule">Schedule</a> used to fire this notification. Only available for iOS. | 4.0.0 |
|
|
620
|
+
| **`sound`** | <code>string</code> | Sound that was used when the notification was displayed. Only available for iOS. | 4.0.0 |
|
|
621
|
+
|
|
622
|
+
|
|
540
623
|
#### Channel
|
|
541
624
|
|
|
542
|
-
| Prop | Type | Description | Since |
|
|
543
|
-
| ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
544
|
-
| **`id`** | <code>string</code> | The channel identifier. | 1.0.0 |
|
|
545
|
-
| **`name`** | <code>string</code> | The human-friendly name of this channel (presented to the user). | 1.0.0 |
|
|
546
|
-
| **`description`** | <code>string</code> | The description of this channel (presented to the user). | 1.0.0 |
|
|
547
|
-
| **`sound`** | <code>string</code> | The sound that should be played for notifications posted to this channel. Notification channels with an importance of at least `3` should have a sound. The file name of a sound file should be specified relative to the android app `res/raw` directory. If the sound is not provided, or the sound file is not found no sound will be used. | 1.0.0 |
|
|
548
|
-
| **`importance`** | <code><a href="#importance">Importance</a></code> | The level of interruption for notifications posted to this channel. | 1.0.0 |
|
|
549
|
-
| **`visibility`** | <code><a href="#visibility">Visibility</a></code> | The visibility of notifications posted to this channel. This setting is for whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form. | 1.0.0 |
|
|
550
|
-
| **`lights`** | <code>boolean</code> | Whether notifications posted to this channel should display notification lights, on devices that support it. | 1.0.0 |
|
|
551
|
-
| **`lightColor`** | <code>string</code> | The light color for notifications posted to this channel. Only supported if lights are enabled on this channel and the device supports it. Supported color formats are `#RRGGBB` and `#RRGGBBAA`. | 1.0.0 |
|
|
552
|
-
| **`vibration`** | <code>boolean</code> | Whether notifications posted to this channel should vibrate. | 1.0.0 |
|
|
625
|
+
| Prop | Type | Description | Default | Since |
|
|
626
|
+
| ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ----- |
|
|
627
|
+
| **`id`** | <code>string</code> | The channel identifier. | | 1.0.0 |
|
|
628
|
+
| **`name`** | <code>string</code> | The human-friendly name of this channel (presented to the user). | | 1.0.0 |
|
|
629
|
+
| **`description`** | <code>string</code> | The description of this channel (presented to the user). | | 1.0.0 |
|
|
630
|
+
| **`sound`** | <code>string</code> | The sound that should be played for notifications posted to this channel. Notification channels with an importance of at least `3` should have a sound. The file name of a sound file should be specified relative to the android app `res/raw` directory. If the sound is not provided, or the sound file is not found no sound will be used. | | 1.0.0 |
|
|
631
|
+
| **`importance`** | <code><a href="#importance">Importance</a></code> | The level of interruption for notifications posted to this channel. | <code>`3`</code> | 1.0.0 |
|
|
632
|
+
| **`visibility`** | <code><a href="#visibility">Visibility</a></code> | The visibility of notifications posted to this channel. This setting is for whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form. | | 1.0.0 |
|
|
633
|
+
| **`lights`** | <code>boolean</code> | Whether notifications posted to this channel should display notification lights, on devices that support it. | | 1.0.0 |
|
|
634
|
+
| **`lightColor`** | <code>string</code> | The light color for notifications posted to this channel. Only supported if lights are enabled on this channel and the device supports it. Supported color formats are `#RRGGBB` and `#RRGGBBAA`. | | 1.0.0 |
|
|
635
|
+
| **`vibration`** | <code>boolean</code> | Whether notifications posted to this channel should vibrate. | | 1.0.0 |
|
|
553
636
|
|
|
554
637
|
|
|
555
638
|
#### ListChannelsResult
|
|
@@ -590,11 +673,6 @@ An action that can be taken when a notification is displayed.
|
|
|
590
673
|
<code>'year' | 'month' | 'two-weeks' | 'week' | 'day' | 'hour' | 'minute' | 'second'</code>
|
|
591
674
|
|
|
592
675
|
|
|
593
|
-
#### NotificationChannel
|
|
594
|
-
|
|
595
|
-
<code><a href="#channel">Channel</a></code>
|
|
596
|
-
|
|
597
|
-
|
|
598
676
|
#### Importance
|
|
599
677
|
|
|
600
678
|
The importance level. For more details, see the [Android Developer Docs](https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT)
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
@@ -11,17 +11,17 @@ buildscript {
|
|
|
11
11
|
mavenCentral()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
22
22
|
defaultConfig {
|
|
23
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
25
25
|
versionCode 1
|
|
26
26
|
versionName "1.0"
|
|
27
27
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -36,15 +36,14 @@ android {
|
|
|
36
36
|
abortOnError false
|
|
37
37
|
}
|
|
38
38
|
compileOptions {
|
|
39
|
-
sourceCompatibility JavaVersion.
|
|
40
|
-
targetCompatibility JavaVersion.
|
|
39
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
40
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
repositories {
|
|
45
45
|
google()
|
|
46
46
|
mavenCentral()
|
|
47
|
-
jcenter()
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
|
|
@@ -22,7 +22,7 @@ import com.getcapacitor.CapConfig;
|
|
|
22
22
|
import com.getcapacitor.JSObject;
|
|
23
23
|
import com.getcapacitor.Logger;
|
|
24
24
|
import com.getcapacitor.PluginCall;
|
|
25
|
-
import com.getcapacitor.
|
|
25
|
+
import com.getcapacitor.PluginConfig;
|
|
26
26
|
import com.getcapacitor.plugin.util.AssetUtil;
|
|
27
27
|
import java.text.SimpleDateFormat;
|
|
28
28
|
import java.util.Date;
|
|
@@ -36,7 +36,6 @@ import org.json.JSONObject;
|
|
|
36
36
|
*/
|
|
37
37
|
public class LocalNotificationManager {
|
|
38
38
|
|
|
39
|
-
private static final String CONFIG_KEY_PREFIX = "plugins.LocalNotifications.";
|
|
40
39
|
private static int defaultSoundID = AssetUtil.RESOURCE_ID_ZERO_VALUE;
|
|
41
40
|
private static int defaultSmallIconID = AssetUtil.RESOURCE_ID_ZERO_VALUE;
|
|
42
41
|
// Action constants
|
|
@@ -52,13 +51,13 @@ public class LocalNotificationManager {
|
|
|
52
51
|
private Context context;
|
|
53
52
|
private Activity activity;
|
|
54
53
|
private NotificationStorage storage;
|
|
55
|
-
private
|
|
54
|
+
private PluginConfig config;
|
|
56
55
|
|
|
57
56
|
public LocalNotificationManager(NotificationStorage notificationStorage, Activity activity, Context context, CapConfig config) {
|
|
58
57
|
storage = notificationStorage;
|
|
59
58
|
this.activity = activity;
|
|
60
59
|
this.context = context;
|
|
61
|
-
this.config = config;
|
|
60
|
+
this.config = config.getPluginConfiguration("LocalNotifications");
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/**
|
|
@@ -223,7 +222,7 @@ public class LocalNotificationManager {
|
|
|
223
222
|
mBuilder.setSmallIcon(localNotification.getSmallIcon(context, getDefaultSmallIcon(context)));
|
|
224
223
|
mBuilder.setLargeIcon(localNotification.getLargeIcon(context));
|
|
225
224
|
|
|
226
|
-
String iconColor = localNotification.getIconColor(config.getString(
|
|
225
|
+
String iconColor = localNotification.getIconColor(config.getString("iconColor"));
|
|
227
226
|
if (iconColor != null) {
|
|
228
227
|
try {
|
|
229
228
|
mBuilder.setColor(Color.parseColor(iconColor));
|
|
@@ -253,13 +252,11 @@ public class LocalNotificationManager {
|
|
|
253
252
|
private void createActionIntents(LocalNotification localNotification, NotificationCompat.Builder mBuilder) {
|
|
254
253
|
// Open intent
|
|
255
254
|
Intent intent = buildIntent(localNotification, DEFAULT_PRESS_ACTION);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
PendingIntent.FLAG_CANCEL_CURRENT
|
|
262
|
-
);
|
|
255
|
+
int flags = PendingIntent.FLAG_CANCEL_CURRENT;
|
|
256
|
+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
257
|
+
flags = flags | PendingIntent.FLAG_MUTABLE;
|
|
258
|
+
}
|
|
259
|
+
PendingIntent pendingIntent = PendingIntent.getActivity(context, localNotification.getId(), intent, flags);
|
|
263
260
|
mBuilder.setContentIntent(pendingIntent);
|
|
264
261
|
|
|
265
262
|
// Build action types
|
|
@@ -273,7 +270,7 @@ public class LocalNotificationManager {
|
|
|
273
270
|
context,
|
|
274
271
|
localNotification.getId() + notificationAction.getId().hashCode(),
|
|
275
272
|
actionIntent,
|
|
276
|
-
|
|
273
|
+
flags
|
|
277
274
|
);
|
|
278
275
|
NotificationCompat.Action.Builder actionBuilder = new NotificationCompat.Action.Builder(
|
|
279
276
|
R.drawable.ic_transparent,
|
|
@@ -295,7 +292,11 @@ public class LocalNotificationManager {
|
|
|
295
292
|
dissmissIntent.putExtra(ACTION_INTENT_KEY, "dismiss");
|
|
296
293
|
LocalNotificationSchedule schedule = localNotification.getSchedule();
|
|
297
294
|
dissmissIntent.putExtra(NOTIFICATION_IS_REMOVABLE_KEY, schedule == null || schedule.isRemovable());
|
|
298
|
-
|
|
295
|
+
flags = 0;
|
|
296
|
+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
297
|
+
flags = PendingIntent.FLAG_MUTABLE;
|
|
298
|
+
}
|
|
299
|
+
PendingIntent deleteIntent = PendingIntent.getBroadcast(context, localNotification.getId(), dissmissIntent, flags);
|
|
299
300
|
mBuilder.setDeleteIntent(deleteIntent);
|
|
300
301
|
}
|
|
301
302
|
|
|
@@ -330,12 +331,11 @@ public class LocalNotificationManager {
|
|
|
330
331
|
Intent notificationIntent = new Intent(context, TimedNotificationPublisher.class);
|
|
331
332
|
notificationIntent.putExtra(NOTIFICATION_INTENT_KEY, request.getId());
|
|
332
333
|
notificationIntent.putExtra(TimedNotificationPublisher.NOTIFICATION_KEY, notification);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
);
|
|
334
|
+
int flags = PendingIntent.FLAG_CANCEL_CURRENT;
|
|
335
|
+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
336
|
+
flags = flags | PendingIntent.FLAG_MUTABLE;
|
|
337
|
+
}
|
|
338
|
+
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent, flags);
|
|
339
339
|
|
|
340
340
|
// Schedule at specific time (with repeating support)
|
|
341
341
|
Date at = schedule.getAt();
|
|
@@ -348,11 +348,7 @@ public class LocalNotificationManager {
|
|
|
348
348
|
long interval = at.getTime() - new Date().getTime();
|
|
349
349
|
alarmManager.setRepeating(AlarmManager.RTC, at.getTime(), interval, pendingIntent);
|
|
350
350
|
} else {
|
|
351
|
-
|
|
352
|
-
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC, at.getTime(), pendingIntent);
|
|
353
|
-
} else {
|
|
354
|
-
alarmManager.setExact(AlarmManager.RTC, at.getTime(), pendingIntent);
|
|
355
|
-
}
|
|
351
|
+
setExactIfPossible(alarmManager, schedule, at.getTime(), pendingIntent);
|
|
356
352
|
}
|
|
357
353
|
return;
|
|
358
354
|
}
|
|
@@ -373,15 +369,31 @@ public class LocalNotificationManager {
|
|
|
373
369
|
if (on != null) {
|
|
374
370
|
long trigger = on.nextTrigger(new Date());
|
|
375
371
|
notificationIntent.putExtra(TimedNotificationPublisher.CRON_KEY, on.toMatchString());
|
|
376
|
-
pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent,
|
|
372
|
+
pendingIntent = PendingIntent.getBroadcast(context, request.getId(), notificationIntent, flags);
|
|
373
|
+
setExactIfPossible(alarmManager, schedule, trigger, pendingIntent);
|
|
374
|
+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
375
|
+
Logger.debug(Logger.tags("LN"), "notification " + request.getId() + " will next fire at " + sdf.format(new Date(trigger)));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
private void setExactIfPossible(
|
|
380
|
+
AlarmManager alarmManager,
|
|
381
|
+
LocalNotificationSchedule schedule,
|
|
382
|
+
long trigger,
|
|
383
|
+
PendingIntent pendingIntent
|
|
384
|
+
) {
|
|
385
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) {
|
|
386
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && schedule.allowWhileIdle()) {
|
|
387
|
+
alarmManager.setAndAllowWhileIdle(AlarmManager.RTC, trigger, pendingIntent);
|
|
388
|
+
} else {
|
|
389
|
+
alarmManager.set(AlarmManager.RTC, trigger, pendingIntent);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
377
392
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && schedule.allowWhileIdle()) {
|
|
378
393
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC, trigger, pendingIntent);
|
|
379
394
|
} else {
|
|
380
395
|
alarmManager.setExact(AlarmManager.RTC, trigger, pendingIntent);
|
|
381
396
|
}
|
|
382
|
-
|
|
383
|
-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
384
|
-
Logger.debug(Logger.tags("LN"), "notification " + request.getId() + " will next fire at " + sdf.format(new Date(trigger)));
|
|
385
397
|
}
|
|
386
398
|
}
|
|
387
399
|
|
|
@@ -399,7 +411,11 @@ public class LocalNotificationManager {
|
|
|
399
411
|
|
|
400
412
|
private void cancelTimerForNotification(Integer notificationId) {
|
|
401
413
|
Intent intent = new Intent(context, TimedNotificationPublisher.class);
|
|
402
|
-
|
|
414
|
+
int flags = 0;
|
|
415
|
+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
416
|
+
flags = PendingIntent.FLAG_MUTABLE;
|
|
417
|
+
}
|
|
418
|
+
PendingIntent pi = PendingIntent.getBroadcast(context, notificationId, intent, flags);
|
|
403
419
|
if (pi != null) {
|
|
404
420
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
|
405
421
|
alarmManager.cancel(pi);
|
|
@@ -428,7 +444,7 @@ public class LocalNotificationManager {
|
|
|
428
444
|
if (defaultSoundID != AssetUtil.RESOURCE_ID_ZERO_VALUE) return defaultSoundID;
|
|
429
445
|
|
|
430
446
|
int resId = AssetUtil.RESOURCE_ID_ZERO_VALUE;
|
|
431
|
-
String soundConfigResourceName = config.getString(
|
|
447
|
+
String soundConfigResourceName = config.getString("sound");
|
|
432
448
|
soundConfigResourceName = AssetUtil.getResourceBaseName(soundConfigResourceName);
|
|
433
449
|
|
|
434
450
|
if (soundConfigResourceName != null) {
|
|
@@ -443,7 +459,7 @@ public class LocalNotificationManager {
|
|
|
443
459
|
if (defaultSmallIconID != AssetUtil.RESOURCE_ID_ZERO_VALUE) return defaultSmallIconID;
|
|
444
460
|
|
|
445
461
|
int resId = AssetUtil.RESOURCE_ID_ZERO_VALUE;
|
|
446
|
-
String smallIconConfigResourceName = config.getString(
|
|
462
|
+
String smallIconConfigResourceName = config.getString("smallIcon");
|
|
447
463
|
smallIconConfigResourceName = AssetUtil.getResourceBaseName(smallIconConfigResourceName);
|
|
448
464
|
|
|
449
465
|
if (smallIconConfigResourceName != null) {
|
|
@@ -5,6 +5,7 @@ import static android.os.Build.VERSION.SDK_INT;
|
|
|
5
5
|
import android.content.BroadcastReceiver;
|
|
6
6
|
import android.content.Context;
|
|
7
7
|
import android.content.Intent;
|
|
8
|
+
import android.os.Build;
|
|
8
9
|
import android.os.UserManager;
|
|
9
10
|
import com.getcapacitor.CapConfig;
|
|
10
11
|
import java.util.ArrayList;
|
|
@@ -15,7 +16,7 @@ public class LocalNotificationRestoreReceiver extends BroadcastReceiver {
|
|
|
15
16
|
|
|
16
17
|
@Override
|
|
17
18
|
public void onReceive(Context context, Intent intent) {
|
|
18
|
-
if (SDK_INT >=
|
|
19
|
+
if (SDK_INT >= Build.VERSION_CODES.N) {
|
|
19
20
|
UserManager um = context.getSystemService(UserManager.class);
|
|
20
21
|
if (um == null || !um.isUserUnlocked()) return;
|
|
21
22
|
}
|
|
@@ -141,7 +141,8 @@ public class LocalNotificationSchedule {
|
|
|
141
141
|
public Long getEveryInterval() {
|
|
142
142
|
switch (every) {
|
|
143
143
|
case "year":
|
|
144
|
-
|
|
144
|
+
// This case is just approximation as not all years have the same number of days
|
|
145
|
+
return count * DateUtils.WEEK_IN_MILLIS * 52;
|
|
145
146
|
case "month":
|
|
146
147
|
// This case is just approximation as months have different number of days
|
|
147
148
|
return count * 30 * DateUtils.DAY_IN_MILLIS;
|