@capacitor/push-notifications 1.0.7 → 4.0.0-beta.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 CHANGED
@@ -3,6 +3,62 @@
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
+ * **push-notifications:** use id and tag for canceling active notification ([#1041](https://github.com/ionic-team/capacitor-plugins/issues/1041)) ([fa710a6](https://github.com/ionic-team/capacitor-plugins/commit/fa710a63ea87f0ec0a7b0059baacfad7a45f8558))
12
+ * correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
13
+ * 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))
14
+ * 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))
15
+ * remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
16
+ * **ios:** Coerce 'extra' field to add missing notification data on events ([#231](https://github.com/ionic-team/capacitor-plugins/issues/231)) ([46ce6b2](https://github.com/ionic-team/capacitor-plugins/commit/46ce6b2a72e4b107702b0cfb97007aaf385a3106))
17
+ * **ios:** do not show notifications when in foreground ([#209](https://github.com/ionic-team/capacitor-plugins/issues/209)) ([1994997](https://github.com/ionic-team/capacitor-plugins/commit/1994997a100d7c57477305d933fb835cf9f7c9c8))
18
+ * **push-notifications:** bump iOS deployment target to 12.0 ([#183](https://github.com/ionic-team/capacitor-plugins/issues/183)) ([d5b6503](https://github.com/ionic-team/capacitor-plugins/commit/d5b650312cded1606e39bbddc62acc6af9545997))
19
+ * **push-notifications:** make removeAllListeners available ([#454](https://github.com/ionic-team/capacitor-plugins/issues/454)) ([d92c925](https://github.com/ionic-team/capacitor-plugins/commit/d92c92566b15d3b339e9a4c54471b65fda49a7f0))
20
+ * **push-notifications:** proper return of push notification object properties ([#349](https://github.com/ionic-team/capacitor-plugins/issues/349)) ([733fc06](https://github.com/ionic-team/capacitor-plugins/commit/733fc06af7b62a576fb6214a7fe42838a3bcb93a))
21
+ * **push-notifications:** Throw errors if missing mandatory channel fields ([#576](https://github.com/ionic-team/capacitor-plugins/issues/576)) ([50f4e70](https://github.com/ionic-team/capacitor-plugins/commit/50f4e7026e5cae5f0871d4863bfab36989208064))
22
+ * 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))
23
+ * export all TS definitions ([6cd2996](https://github.com/ionic-team/capacitor-plugins/commit/6cd299660fdeb27382ec7f45f0b3a55224cd0ad1))
24
+ * support deprecated types from Capacitor 2 ([#210](https://github.com/ionic-team/capacitor-plugins/issues/210)) ([b559e24](https://github.com/ionic-team/capacitor-plugins/commit/b559e24b24174be60129217e87c0bff14bcdd573))
25
+ * **push-notifications:** remove unused Firebase/Messaging dependency ([#186](https://github.com/ionic-team/capacitor-plugins/issues/186)) ([0f4ca7c](https://github.com/ionic-team/capacitor-plugins/commit/0f4ca7ceaf67ced40b2cf2b359001b1ab060a3a6))
26
+
27
+
28
+ ### Features
29
+
30
+ * 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))
31
+ * **push-notifications:** Allow to show while in foreground ([#919](https://github.com/ionic-team/capacitor-plugins/issues/919)) ([a90b5fd](https://github.com/ionic-team/capacitor-plugins/commit/a90b5fd4fe82d660c96a8be55e360d15f9e5e8c6))
32
+ * Use java 11 ([#910](https://github.com/ionic-team/capacitor-plugins/issues/910)) ([5acb2a2](https://github.com/ionic-team/capacitor-plugins/commit/5acb2a288a413492b163e4e97da46a085d9e4be0))
33
+ * **push-notifications:** Add new type for registrationError ([#808](https://github.com/ionic-team/capacitor-plugins/issues/808)) ([e5e78bb](https://github.com/ionic-team/capacitor-plugins/commit/e5e78bbbff020e625ccfd49c8ae36b4f1609a242))
34
+ * add commonjs output format ([#179](https://github.com/ionic-team/capacitor-plugins/issues/179)) ([8e9e098](https://github.com/ionic-team/capacitor-plugins/commit/8e9e09862064b3f6771d7facbc4008e995d9b463))
35
+ * Push Notifications plugin ([#126](https://github.com/ionic-team/capacitor-plugins/issues/126)) ([0bcd833](https://github.com/ionic-team/capacitor-plugins/commit/0bcd833a6503061be45253b21fca9bd75576efc8))
36
+ * 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))
37
+ * 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))
38
+
39
+
40
+
41
+
42
+
43
+ ## [1.0.9](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.8...@capacitor/push-notifications@1.0.9) (2022-01-19)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * 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))
49
+
50
+
51
+
52
+
53
+
54
+ ## [1.0.8](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.7...@capacitor/push-notifications@1.0.8) (2022-01-10)
55
+
56
+ **Note:** Version bump only for package @capacitor/push-notifications
57
+
58
+
59
+
60
+
61
+
6
62
  ## [1.0.7](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.6...@capacitor/push-notifications@1.0.7) (2021-11-03)
7
63
 
8
64
  **Note:** Version bump only for package @capacitor/push-notifications
@@ -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}', 'push-notifications/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '12.0'
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
@@ -33,7 +33,7 @@ The Push Notification API uses [Firebase Cloud Messaging](https://firebase.googl
33
33
 
34
34
  This plugin will use the following project variables (defined in your app's `variables.gradle` file):
35
35
 
36
- - `$firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `21.0.1`)
36
+ - `$firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `23.0.5`)
37
37
 
38
38
  ---
39
39
 
@@ -54,11 +54,11 @@ Android Studio has an icon generator you can use to create your Push Notificatio
54
54
  <docgen-config>
55
55
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
56
56
 
57
- On iOS you can configure the way the push notifications are displayed when the app is in foreground.
57
+ You can configure the way the push notifications are displayed when the app is in foreground.
58
58
 
59
- | Prop | Type | Description | Since |
60
- | ------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
61
- | **`presentationOptions`** | <code>PresentationOption[]</code> | This is an array of strings you can combine. Possible values in the array are: - `badge`: badge count on the app icon is updated (default value) - `sound`: the device will ring/vibrate when the push notification is received - `alert`: the push notification is displayed in a native dialog An empty array can be provided if none of the options are desired. Only available for iOS. | 1.0.0 |
59
+ | Prop | Type | Description | Since |
60
+ | ------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
61
+ | **`presentationOptions`** | <code>PresentationOption[]</code> | This is an array of strings you can combine. Possible values in the array are: - `badge`: badge count on the app icon is updated (default value) - `sound`: the device will ring/vibrate when the push notification is received - `alert`: the push notification is displayed in a native dialog An empty array can be provided if none of the options are desired. badge is only available for iOS. | 1.0.0 |
62
62
 
63
63
  ### Examples
64
64
 
@@ -109,6 +109,49 @@ On Android, there are various system and app states that can affect the delivery
109
109
 
110
110
  ---
111
111
 
112
+ ## Example
113
+
114
+ ```typescript
115
+ import { PushNotifications } from '@capacitor/push-notifications';
116
+
117
+ const addListeners = async () => {
118
+ await PushNotifications.addListener('registration', token => {
119
+ console.info('Registration token: ', token.value);
120
+ });
121
+
122
+ await PushNotifications.addListener('registrationError', err => {
123
+ console.error('Registration error: ', err.error);
124
+ });
125
+
126
+ await PushNotifications.addListener('pushNotificationReceived', notification => {
127
+ console.log('Push notification received: ', notification);
128
+ });
129
+
130
+ await PushNotifications.addListener('pushNotificationActionPerformed', notification => {
131
+ console.log('Push notification action performed', notification.actionId, notification.inputValue);
132
+ });
133
+ }
134
+
135
+ const registerNotifications = async () => {
136
+ let permStatus = await PushNotifications.checkPermissions();
137
+
138
+ if (permStatus.receive === 'prompt') {
139
+ permStatus = await PushNotifications.requestPermissions();
140
+ }
141
+
142
+ if (permStatus.receive !== 'granted') {
143
+ throw new Error('User denied permissions!');
144
+ }
145
+
146
+ await PushNotifications.register();
147
+ }
148
+
149
+ const getDeliveredNotifications = async () => {
150
+ const notificationList = await PushNotifications.getDeliveredNotifications();
151
+ console.log('delivered notifications', notificationList);
152
+ }
153
+ ```
154
+
112
155
  ## API
113
156
 
114
157
  <docgen-index>
@@ -219,16 +262,16 @@ Only available on Android O or newer (SDK 26+).
219
262
  ### deleteChannel(...)
220
263
 
221
264
  ```typescript
222
- deleteChannel(channel: Channel) => Promise<void>
265
+ deleteChannel(args: { id: string; }) => Promise<void>
223
266
  ```
224
267
 
225
268
  Delete a notification channel.
226
269
 
227
270
  Only available on Android O or newer (SDK 26+).
228
271
 
229
- | Param | Type |
230
- | ------------- | ------------------------------------------- |
231
- | **`channel`** | <code><a href="#channel">Channel</a></code> |
272
+ | Param | Type |
273
+ | ---------- | ---------------------------- |
274
+ | **`args`** | <code>{ id: string; }</code> |
232
275
 
233
276
  **Since:** 1.0.0
234
277
 
@@ -319,17 +362,17 @@ Provides the push notification token.
319
362
  ### addListener('registrationError', ...)
320
363
 
321
364
  ```typescript
322
- addListener(eventName: 'registrationError', listenerFunc: (error: any) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
365
+ addListener(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
323
366
  ```
324
367
 
325
368
  Called when the push notification registration finished with problems.
326
369
 
327
370
  Provides an error with the registration problem.
328
371
 
329
- | Param | Type |
330
- | ------------------ | ------------------------------------ |
331
- | **`eventName`** | <code>'registrationError'</code> |
332
- | **`listenerFunc`** | <code>(error: any) =&gt; void</code> |
372
+ | Param | Type |
373
+ | ------------------ | ----------------------------------------------------------------------------------- |
374
+ | **`eventName`** | <code>'registrationError'</code> |
375
+ | **`listenerFunc`** | <code>(error: <a href="#registrationerror">RegistrationError</a>) =&gt; void</code> |
333
376
 
334
377
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
335
378
 
@@ -409,6 +452,7 @@ Remove all native listeners for this plugin.
409
452
  | **`subtitle`** | <code>string</code> | The notification subtitle. | 1.0.0 |
410
453
  | **`body`** | <code>string</code> | The main text payload for the notification. | 1.0.0 |
411
454
  | **`id`** | <code>string</code> | The notification identifier. | 1.0.0 |
455
+ | **`tag`** | <code>string</code> | The notification tag. Only available on Android (from push notifications). | 4.0.0 |
412
456
  | **`badge`** | <code>number</code> | The number to display for the app icon badge. | 1.0.0 |
413
457
  | **`notification`** | <code>any</code> | It's not being returned. | 1.0.0 |
414
458
  | **`data`** | <code>any</code> | Any additional data that was included in the push notification payload. | 1.0.0 |
@@ -420,17 +464,17 @@ Remove all native listeners for this plugin.
420
464
 
421
465
  #### Channel
422
466
 
423
- | Prop | Type | Description | Since |
424
- | ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
425
- | **`id`** | <code>string</code> | The channel identifier. | 1.0.0 |
426
- | **`name`** | <code>string</code> | The human-friendly name of this channel (presented to the user). | 1.0.0 |
427
- | **`description`** | <code>string</code> | The description of this channel (presented to the user). | 1.0.0 |
428
- | **`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. | 1.0.0 |
429
- | **`importance`** | <code><a href="#importance">Importance</a></code> | The level of interruption for notifications posted to this channel. | 1.0.0 |
430
- | **`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 |
431
- | **`lights`** | <code>boolean</code> | Whether notifications posted to this channel should display notification lights, on devices that support it. | 1.0.0 |
432
- | **`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 |
433
- | **`vibration`** | <code>boolean</code> | Whether notifications posted to this channel should vibrate. | 1.0.0 |
467
+ | Prop | Type | Description | Default | Since |
468
+ | ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ----- |
469
+ | **`id`** | <code>string</code> | The channel identifier. | | 1.0.0 |
470
+ | **`name`** | <code>string</code> | The human-friendly name of this channel (presented to the user). | | 1.0.0 |
471
+ | **`description`** | <code>string</code> | The description of this channel (presented to the user). | | 1.0.0 |
472
+ | **`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. | | 1.0.0 |
473
+ | **`importance`** | <code><a href="#importance">Importance</a></code> | The level of interruption for notifications posted to this channel. | <code>`3`</code> | 1.0.0 |
474
+ | **`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 |
475
+ | **`lights`** | <code>boolean</code> | Whether notifications posted to this channel should display notification lights, on devices that support it. | | 1.0.0 |
476
+ | **`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 |
477
+ | **`vibration`** | <code>boolean</code> | Whether notifications posted to this channel should vibrate. | | 1.0.0 |
434
478
 
435
479
 
436
480
  #### ListChannelsResult
@@ -461,6 +505,13 @@ Remove all native listeners for this plugin.
461
505
  | **`value`** | <code>string</code> | On iOS it contains the APNS token. On Android it contains the FCM token. | 1.0.0 |
462
506
 
463
507
 
508
+ #### RegistrationError
509
+
510
+ | Prop | Type | Description | Since |
511
+ | ----------- | ------------------- | -------------------------------------------------- | ----- |
512
+ | **`error`** | <code>string</code> | Error message describing the registration failure. | 4.0.0 |
513
+
514
+
464
515
  #### ActionPerformed
465
516
 
466
517
  | Prop | Type | Description | Since |
@@ -1,9 +1,9 @@
1
1
  ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
6
- firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '21.0.1'
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
+ firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '23.0.5'
7
7
  }
8
8
 
9
9
  buildscript {
@@ -12,17 +12,17 @@ buildscript {
12
12
  mavenCentral()
13
13
  }
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:4.2.1'
15
+ classpath 'com.android.tools.build:gradle:7.2.1'
16
16
  }
17
17
  }
18
18
 
19
19
  apply plugin: 'com.android.library'
20
20
 
21
21
  android {
22
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
23
23
  defaultConfig {
24
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
25
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
26
26
  versionCode 1
27
27
  versionName "1.0"
28
28
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -37,14 +37,13 @@ android {
37
37
  abortOnError false
38
38
  }
39
39
  compileOptions {
40
- sourceCompatibility JavaVersion.VERSION_1_8
41
- targetCompatibility JavaVersion.VERSION_1_8
40
+ sourceCompatibility JavaVersion.VERSION_11
41
+ targetCompatibility JavaVersion.VERSION_11
42
42
  }
43
43
  }
44
44
 
45
45
  repositories {
46
46
  google()
47
- jcenter()
48
47
  mavenCentral()
49
48
  }
50
49
 
@@ -4,25 +4,29 @@ import android.app.NotificationChannel;
4
4
  import android.app.NotificationManager;
5
5
  import android.content.ContentResolver;
6
6
  import android.content.Context;
7
- import android.graphics.Color;
8
7
  import android.media.AudioAttributes;
9
8
  import android.net.Uri;
9
+ import android.os.Build;
10
+ import android.provider.Settings;
10
11
  import androidx.core.app.NotificationCompat;
11
- import com.getcapacitor.JSArray;
12
- import com.getcapacitor.JSObject;
13
- import com.getcapacitor.Logger;
14
- import com.getcapacitor.PluginCall;
12
+ import com.getcapacitor.*;
15
13
  import com.getcapacitor.util.WebColor;
14
+ import java.util.Arrays;
16
15
  import java.util.List;
17
16
 
18
17
  public class NotificationChannelManager {
19
18
 
19
+ public static final String FOREGROUND_NOTIFICATION_CHANNEL_ID = "PushDefaultForeground";
20
+
20
21
  private Context context;
21
22
  private NotificationManager notificationManager;
23
+ private PluginConfig config;
22
24
 
23
- public NotificationChannelManager(Context context, NotificationManager manager) {
25
+ public NotificationChannelManager(Context context, NotificationManager manager, PluginConfig config) {
24
26
  this.context = context;
25
27
  this.notificationManager = manager;
28
+ this.config = config;
29
+ createForegroundNotificationChannel();
26
30
  }
27
31
 
28
32
  private static String CHANNEL_ID = "id";
@@ -50,12 +54,8 @@ public class NotificationChannelManager {
50
54
  call.reject("Channel missing name");
51
55
  return;
52
56
  }
53
- if (call.getInt(CHANNEL_IMPORTANCE) != null) {
54
- channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE));
55
- } else {
56
- call.reject("Channel missing importance");
57
- return;
58
- }
57
+
58
+ channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE, NotificationManager.IMPORTANCE_DEFAULT));
59
59
  channel.put(CHANNEL_DESCRIPTION, call.getString(CHANNEL_DESCRIPTION, ""));
60
60
  channel.put(CHANNEL_VISIBILITY, call.getInt(CHANNEL_VISIBILITY, NotificationCompat.VISIBILITY_PUBLIC));
61
61
  channel.put(CHANNEL_SOUND, call.getString(CHANNEL_SOUND, null));
@@ -140,4 +140,35 @@ public class NotificationChannelManager {
140
140
  call.unavailable();
141
141
  }
142
142
  }
143
+
144
+ /**
145
+ * Create notification channel
146
+ */
147
+ public void createForegroundNotificationChannel() {
148
+ // Create the NotificationChannel only if presentationOptions is defined
149
+ // Because the channel can't be changed after creation
150
+ String[] presentation = config.getArray("presentationOptions");
151
+ if (presentation != null) {
152
+ // And only on API 26+ because the NotificationChannel class
153
+ // is new and not in the support library
154
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
155
+ CharSequence name = "Push Notifications Foreground";
156
+ String description = "Push notifications in foreground";
157
+ int importance = NotificationManager.IMPORTANCE_HIGH;
158
+ NotificationChannel channel = new NotificationChannel(FOREGROUND_NOTIFICATION_CHANNEL_ID, name, importance);
159
+ channel.setDescription(description);
160
+ if (Arrays.asList(presentation).contains("sound")) {
161
+ AudioAttributes audioAttributes = new AudioAttributes.Builder()
162
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
163
+ .setUsage(AudioAttributes.USAGE_ALARM)
164
+ .build();
165
+ channel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, audioAttributes);
166
+ }
167
+ // Register the channel with the system; you can't change the importance
168
+ // or other notification behaviors after this
169
+ android.app.NotificationManager notificationManager = context.getSystemService(android.app.NotificationManager.class);
170
+ notificationManager.createNotificationChannel(channel);
171
+ }
172
+ }
173
+ }
143
174
  }
@@ -4,26 +4,19 @@ import android.app.Notification;
4
4
  import android.app.NotificationManager;
5
5
  import android.content.Context;
6
6
  import android.content.Intent;
7
+ import android.content.pm.ApplicationInfo;
7
8
  import android.net.Uri;
8
9
  import android.os.Build;
9
10
  import android.os.Bundle;
10
11
  import android.service.notification.StatusBarNotification;
11
- import com.getcapacitor.Bridge;
12
- import com.getcapacitor.JSArray;
13
- import com.getcapacitor.JSObject;
14
- import com.getcapacitor.Plugin;
15
- import com.getcapacitor.PluginCall;
16
- import com.getcapacitor.PluginHandle;
17
- import com.getcapacitor.PluginMethod;
12
+ import androidx.core.app.NotificationCompat;
13
+ import com.getcapacitor.*;
18
14
  import com.getcapacitor.annotation.CapacitorPlugin;
19
15
  import com.getcapacitor.annotation.Permission;
20
- import com.google.android.gms.tasks.OnFailureListener;
21
- import com.google.android.gms.tasks.OnSuccessListener;
22
- import com.google.firebase.iid.FirebaseInstanceId;
23
- import com.google.firebase.iid.InstanceIdResult;
24
16
  import com.google.firebase.messaging.FirebaseMessaging;
25
17
  import com.google.firebase.messaging.RemoteMessage;
26
18
  import java.util.ArrayList;
19
+ import java.util.Arrays;
27
20
  import java.util.List;
28
21
  import org.json.JSONException;
29
22
  import org.json.JSONObject;
@@ -50,7 +43,7 @@ public class PushNotificationsPlugin extends Plugin {
50
43
  lastMessage = null;
51
44
  }
52
45
 
53
- notificationChannelManager = new NotificationChannelManager(getActivity(), notificationManager);
46
+ notificationChannelManager = new NotificationChannelManager(getActivity(), notificationManager, getConfig());
54
47
  }
55
48
 
56
49
  @Override
@@ -80,26 +73,16 @@ public class PushNotificationsPlugin extends Plugin {
80
73
  @PluginMethod
81
74
  public void register(PluginCall call) {
82
75
  FirebaseMessaging.getInstance().setAutoInitEnabled(true);
83
- FirebaseInstanceId
76
+ FirebaseMessaging
84
77
  .getInstance()
85
- .getInstanceId()
86
- .addOnSuccessListener(
87
- getActivity(),
88
- new OnSuccessListener<InstanceIdResult>() {
89
- @Override
90
- public void onSuccess(InstanceIdResult instanceIdResult) {
91
- sendToken(instanceIdResult.getToken());
92
- }
93
- }
94
- );
95
- FirebaseInstanceId
96
- .getInstance()
97
- .getInstanceId()
98
- .addOnFailureListener(
99
- new OnFailureListener() {
100
- public void onFailure(Exception e) {
101
- sendError(e.getLocalizedMessage());
78
+ .getToken()
79
+ .addOnCompleteListener(
80
+ task -> {
81
+ if (!task.isSuccessful()) {
82
+ sendError(task.getException().getLocalizedMessage());
83
+ return;
102
84
  }
85
+ sendToken(task.getResult());
103
86
  }
104
87
  );
105
88
  call.resolve();
@@ -115,6 +98,7 @@ public class PushNotificationsPlugin extends Plugin {
115
98
  JSObject jsNotif = new JSObject();
116
99
 
117
100
  jsNotif.put("id", notif.getId());
101
+ jsNotif.put("tag", notif.getTag());
118
102
 
119
103
  Notification notification = notif.getNotification();
120
104
  if (notification != null) {
@@ -145,13 +129,18 @@ public class PushNotificationsPlugin extends Plugin {
145
129
  public void removeDeliveredNotifications(PluginCall call) {
146
130
  JSArray notifications = call.getArray("notifications");
147
131
 
148
- List<Integer> ids = new ArrayList<>();
149
132
  try {
150
133
  for (Object o : notifications.toList()) {
151
134
  if (o instanceof JSONObject) {
152
135
  JSObject notif = JSObject.fromJSONObject((JSONObject) o);
136
+ String tag = notif.getString("tag");
153
137
  Integer id = notif.getInteger("id");
154
- ids.add(id);
138
+
139
+ if (tag == null) {
140
+ notificationManager.cancel(id);
141
+ } else {
142
+ notificationManager.cancel(tag, id);
143
+ }
155
144
  } else {
156
145
  call.reject("Expected notifications to be a list of notification objects");
157
146
  }
@@ -160,10 +149,6 @@ public class PushNotificationsPlugin extends Plugin {
160
149
  call.reject(e.getMessage());
161
150
  }
162
151
 
163
- for (int id : ids) {
164
- notificationManager.cancel(id);
165
- }
166
-
167
152
  call.resolve();
168
153
  }
169
154
 
@@ -229,8 +214,30 @@ public class PushNotificationsPlugin extends Plugin {
229
214
 
230
215
  RemoteMessage.Notification notification = remoteMessage.getNotification();
231
216
  if (notification != null) {
232
- remoteMessageData.put("title", notification.getTitle());
233
- remoteMessageData.put("body", notification.getBody());
217
+ String title = notification.getTitle();
218
+ String body = notification.getBody();
219
+ String[] presentation = getConfig().getArray("presentationOptions");
220
+ if (presentation != null) {
221
+ if (Arrays.asList(presentation).contains("alert")) {
222
+ ApplicationInfo applicationInfo = getContext().getApplicationInfo();
223
+ Bundle bundle = applicationInfo.metaData;
224
+ int pushIcon = android.R.drawable.ic_dialog_info;
225
+ if (bundle != null && bundle.getInt("com.google.firebase.messaging.default_notification_icon") != 0) {
226
+ pushIcon = bundle.getInt("com.google.firebase.messaging.default_notification_icon");
227
+ }
228
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(
229
+ getContext(),
230
+ NotificationChannelManager.FOREGROUND_NOTIFICATION_CHANNEL_ID
231
+ )
232
+ .setSmallIcon(pushIcon)
233
+ .setContentTitle(title)
234
+ .setContentText(body)
235
+ .setPriority(NotificationCompat.PRIORITY_DEFAULT);
236
+ notificationManager.notify(0, builder.build());
237
+ }
238
+ }
239
+ remoteMessageData.put("title", title);
240
+ remoteMessageData.put("body", body);
234
241
  remoteMessageData.put("click_action", notification.getClickAction());
235
242
 
236
243
  Uri link = notification.getLink();
package/dist/docs.json CHANGED
@@ -100,12 +100,12 @@
100
100
  },
101
101
  {
102
102
  "name": "deleteChannel",
103
- "signature": "(channel: Channel) => Promise<void>",
103
+ "signature": "(args: { id: string; }) => Promise<void>",
104
104
  "parameters": [
105
105
  {
106
- "name": "channel",
106
+ "name": "args",
107
107
  "docs": "",
108
- "type": "Channel"
108
+ "type": "{ id: string; }"
109
109
  }
110
110
  ],
111
111
  "returns": "Promise<void>",
@@ -116,9 +116,7 @@
116
116
  }
117
117
  ],
118
118
  "docs": "Delete a notification channel.\n\nOnly available on Android O or newer (SDK 26+).",
119
- "complexTypes": [
120
- "Channel"
121
- ],
119
+ "complexTypes": [],
122
120
  "slug": "deletechannel"
123
121
  },
124
122
  {
@@ -203,7 +201,7 @@
203
201
  },
204
202
  {
205
203
  "name": "addListener",
206
- "signature": "(eventName: 'registrationError', listenerFunc: (error: any) => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
204
+ "signature": "(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
207
205
  "parameters": [
208
206
  {
209
207
  "name": "eventName",
@@ -213,7 +211,7 @@
213
211
  {
214
212
  "name": "listenerFunc",
215
213
  "docs": "",
216
- "type": "(error: any) => void"
214
+ "type": "(error: RegistrationError) => void"
217
215
  }
218
216
  ],
219
217
  "returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
@@ -225,7 +223,8 @@
225
223
  ],
226
224
  "docs": "Called when the push notification registration finished with problems.\n\nProvides an error with the registration problem.",
227
225
  "complexTypes": [
228
- "PluginListenerHandle"
226
+ "PluginListenerHandle",
227
+ "RegistrationError"
229
228
  ],
230
229
  "slug": "addlistenerregistrationerror"
231
230
  },
@@ -384,6 +383,18 @@
384
383
  "complexTypes": [],
385
384
  "type": "string"
386
385
  },
386
+ {
387
+ "name": "tag",
388
+ "tags": [
389
+ {
390
+ "text": "4.0.0",
391
+ "name": "since"
392
+ }
393
+ ],
394
+ "docs": "The notification tag.\n\nOnly available on Android (from push notifications).",
395
+ "complexTypes": [],
396
+ "type": "string | undefined"
397
+ },
387
398
  {
388
399
  "name": "badge",
389
400
  "tags": [
@@ -536,6 +547,10 @@
536
547
  {
537
548
  "name": "importance",
538
549
  "tags": [
550
+ {
551
+ "text": "`3`",
552
+ "name": "default"
553
+ },
539
554
  {
540
555
  "text": "1.0.0",
541
556
  "name": "since"
@@ -682,6 +697,27 @@
682
697
  }
683
698
  ]
684
699
  },
700
+ {
701
+ "name": "RegistrationError",
702
+ "slug": "registrationerror",
703
+ "docs": "",
704
+ "tags": [],
705
+ "methods": [],
706
+ "properties": [
707
+ {
708
+ "name": "error",
709
+ "tags": [
710
+ {
711
+ "text": "4.0.0",
712
+ "name": "since"
713
+ }
714
+ ],
715
+ "docs": "Error message describing the registration failure.",
716
+ "complexTypes": [],
717
+ "type": "string"
718
+ }
719
+ ]
720
+ },
685
721
  {
686
722
  "name": "ActionPerformed",
687
723
  "slug": "actionperformed",
@@ -819,14 +855,14 @@
819
855
  "name": "example"
820
856
  }
821
857
  ],
822
- "docs": "This is an array of strings you can combine. Possible values in the array are:\n - `badge`: badge count on the app icon is updated (default value)\n - `sound`: the device will ring/vibrate when the push notification is received\n - `alert`: the push notification is displayed in a native dialog\n\nAn empty array can be provided if none of the options are desired.\n\nOnly available for iOS.",
858
+ "docs": "This is an array of strings you can combine. Possible values in the array are:\n - `badge`: badge count on the app icon is updated (default value)\n - `sound`: the device will ring/vibrate when the push notification is received\n - `alert`: the push notification is displayed in a native dialog\n\nAn empty array can be provided if none of the options are desired.\n\nbadge is only available for iOS.",
823
859
  "complexTypes": [
824
860
  "PresentationOption"
825
861
  ],
826
862
  "type": "PresentationOption[]"
827
863
  }
828
864
  ],
829
- "docs": "On iOS you can configure the way the push notifications are displayed when the app is in foreground."
865
+ "docs": "You can configure the way the push notifications are displayed when the app is in foreground."
830
866
  }
831
867
  ]
832
868
  }
@@ -3,7 +3,7 @@ export declare type PresentationOption = 'badge' | 'sound' | 'alert';
3
3
  declare module '@capacitor/cli' {
4
4
  interface PluginsConfig {
5
5
  /**
6
- * On iOS you can configure the way the push notifications are displayed when the app is in foreground.
6
+ * You can configure the way the push notifications are displayed when the app is in foreground.
7
7
  */
8
8
  PushNotifications?: {
9
9
  /**
@@ -14,7 +14,7 @@ declare module '@capacitor/cli' {
14
14
  *
15
15
  * An empty array can be provided if none of the options are desired.
16
16
  *
17
- * Only available for iOS.
17
+ * badge is only available for iOS.
18
18
  *
19
19
  * @since 1.0.0
20
20
  * @example ["badge", "sound", "alert"]
@@ -67,7 +67,9 @@ export interface PushNotificationsPlugin {
67
67
  *
68
68
  * @since 1.0.0
69
69
  */
70
- deleteChannel(channel: Channel): Promise<void>;
70
+ deleteChannel(args: {
71
+ id: string;
72
+ }): Promise<void>;
71
73
  /**
72
74
  * List the available notification channels.
73
75
  *
@@ -115,7 +117,7 @@ export interface PushNotificationsPlugin {
115
117
  *
116
118
  * @since 1.0.0
117
119
  */
118
- addListener(eventName: 'registrationError', listenerFunc: (error: any) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
120
+ addListener(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
119
121
  /**
120
122
  * Called when the device receives a push notification.
121
123
  *
@@ -160,6 +162,14 @@ export interface PushNotificationSchema {
160
162
  * @since 1.0.0
161
163
  */
162
164
  id: string;
165
+ /**
166
+ * The notification tag.
167
+ *
168
+ * Only available on Android (from push notifications).
169
+ *
170
+ * @since 4.0.0
171
+ */
172
+ tag?: string;
163
173
  /**
164
174
  * The number to display for the app icon badge.
165
175
  *
@@ -244,6 +254,14 @@ export interface Token {
244
254
  */
245
255
  value: string;
246
256
  }
257
+ export interface RegistrationError {
258
+ /**
259
+ * Error message describing the registration failure.
260
+ *
261
+ * @since 4.0.0
262
+ */
263
+ error: string;
264
+ }
247
265
  export interface DeliveredNotifications {
248
266
  /**
249
267
  * List of notifications that are visible on the
@@ -288,9 +306,10 @@ export interface Channel {
288
306
  /**
289
307
  * The level of interruption for notifications posted to this channel.
290
308
  *
309
+ * @default `3`
291
310
  * @since 1.0.0
292
311
  */
293
- importance: Importance;
312
+ importance?: Importance;
294
313
  /**
295
314
  * The visibility of notifications posted to this channel.
296
315
  *
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC"}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport type PresentationOption = 'badge' | 'sound' | 'alert';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * You can configure the way the push notifications are displayed when the app is in foreground.\n */\n PushNotifications?: {\n /**\n * This is an array of strings you can combine. Possible values in the array are:\n * - `badge`: badge count on the app icon is updated (default value)\n * - `sound`: the device will ring/vibrate when the push notification is received\n * - `alert`: the push notification is displayed in a native dialog\n *\n * An empty array can be provided if none of the options are desired.\n *\n * badge is only available for iOS.\n *\n * @since 1.0.0\n * @example [\"badge\", \"sound\", \"alert\"]\n */\n presentationOptions: PresentationOption[];\n };\n }\n}\n\nexport interface PushNotificationsPlugin {\n /**\n * Register the app to receive push notifications.\n *\n * This method will trigger the `'registration'` event with the push token or\n * `'registrationError'` if there was a problem. It does not prompt the user for\n * notification permissions, use `requestPermissions()` first.\n *\n * @since 1.0.0\n */\n register(): Promise<void>;\n\n /**\n * Get a list of notifications that are visible on the notifications screen.\n *\n * @since 1.0.0\n */\n getDeliveredNotifications(): Promise<DeliveredNotifications>;\n\n /**\n * Remove the specified notifications from the notifications screen.\n *\n * @since 1.0.0\n */\n removeDeliveredNotifications(\n delivered: DeliveredNotifications,\n ): Promise<void>;\n\n /**\n * Remove all the notifications from the notifications screen.\n *\n * @since 1.0.0\n */\n removeAllDeliveredNotifications(): Promise<void>;\n\n /**\n * Create a notification channel.\n *\n * Only available on Android O or newer (SDK 26+).\n *\n * @since 1.0.0\n */\n createChannel(channel: Channel): Promise<void>;\n\n /**\n * Delete a notification channel.\n *\n * Only available on Android O or newer (SDK 26+).\n *\n * @since 1.0.0\n */\n deleteChannel(args: { id: string }): Promise<void>;\n\n /**\n * List the available notification channels.\n *\n * Only available on Android O or newer (SDK 26+).\n *\n * @since 1.0.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Check permission to receive push notifications.\n *\n * On Android the status is always granted because you can always\n * receive push notifications. If you need to check if the user allows\n * to display notifications, use local-notifications plugin.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request permission to receive push notifications.\n *\n * On Android it doesn't prompt for permission because you can always\n * receive push notifications.\n *\n * On iOS, the first time you use the function, it will prompt the user\n * for push notification permission and return granted or denied based\n * on the user selection. On following calls it will currect status of\n * the permission without prompting again.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Called when the push notification registration finishes without problems.\n *\n * Provides the push notification token.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'registration',\n listenerFunc: (token: Token) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Called when the push notification registration finished with problems.\n *\n * Provides an error with the registration problem.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'registrationError',\n listenerFunc: (error: RegistrationError) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Called when the device receives a push notification.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'pushNotificationReceived',\n listenerFunc: (notification: PushNotificationSchema) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Called when an action is performed on a push notification.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'pushNotificationActionPerformed',\n listenerFunc: (notification: ActionPerformed) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all native listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n\nexport interface PushNotificationSchema {\n /**\n * The notification title.\n *\n * @since 1.0.0\n */\n title?: string;\n\n /**\n * The notification subtitle.\n *\n * @since 1.0.0\n */\n subtitle?: string;\n\n /**\n * The main text payload for the notification.\n *\n * @since 1.0.0\n */\n body?: string;\n\n /**\n * The notification identifier.\n *\n * @since 1.0.0\n */\n id: string;\n\n /**\n * The notification tag.\n *\n * Only available on Android (from push notifications).\n *\n * @since 4.0.0\n */\n tag?: string;\n\n /**\n * The number to display for the app icon badge.\n *\n * @since 1.0.0\n */\n badge?: number;\n\n /**\n * It's not being returned.\n *\n * @deprecated will be removed in next major version.\n * @since 1.0.0\n */\n notification?: any;\n\n /**\n * Any additional data that was included in the\n * push notification payload.\n *\n * @since 1.0.0\n */\n data: any;\n\n /**\n * The action to be performed on the user opening the notification.\n *\n * Only available on Android.\n *\n * @since 1.0.0\n */\n click_action?: string;\n\n /**\n * Deep link from the notification.\n *\n * Only available on Android.\n *\n * @since 1.0.0\n */\n link?: string;\n\n /**\n * Set the group identifier for notification grouping.\n *\n * Only available on Android. Works like `threadIdentifier` on iOS.\n *\n * @since 1.0.0\n */\n group?: string;\n\n /**\n * Designate this notification as the summary for an associated `group`.\n *\n * Only available on Android.\n *\n * @since 1.0.0\n */\n groupSummary?: boolean;\n}\n\nexport interface ActionPerformed {\n /**\n * The action performed on the notification.\n *\n * @since 1.0.0\n */\n actionId: string;\n\n /**\n * Text entered on the notification action.\n *\n * Only available on iOS.\n *\n * @since 1.0.0\n */\n inputValue?: string;\n\n /**\n * The notification in which the action was performed.\n *\n * @since 1.0.0\n */\n notification: PushNotificationSchema;\n}\n\nexport interface Token {\n /**\n * On iOS it contains the APNS token.\n * On Android it contains the FCM token.\n *\n * @since 1.0.0\n */\n value: string;\n}\n\nexport interface RegistrationError {\n /**\n * Error message describing the registration failure.\n *\n * @since 4.0.0\n */\n error: string;\n}\n\nexport interface DeliveredNotifications {\n /**\n * List of notifications that are visible on the\n * notifications screen.\n *\n * @since 1.0.0\n */\n notifications: PushNotificationSchema[];\n}\n\nexport interface Channel {\n /**\n * The channel identifier.\n *\n * @since 1.0.0\n */\n id: string;\n\n /**\n * The human-friendly name of this channel (presented to the user).\n *\n * @since 1.0.0\n */\n name: string;\n\n /**\n * The description of this channel (presented to the user).\n *\n * @since 1.0.0\n */\n description?: string;\n\n /**\n * The sound that should be played for notifications posted to this channel.\n *\n * Notification channels with an importance of at least `3` should have a\n * sound.\n *\n * The file name of a sound file should be specified relative to the android\n * app `res/raw` directory.\n *\n * @since 1.0.0\n * @example \"jingle.wav\"\n */\n sound?: string;\n\n /**\n * The level of interruption for notifications posted to this channel.\n *\n * @default `3`\n * @since 1.0.0\n */\n importance?: Importance;\n\n /**\n * The visibility of notifications posted to this channel.\n *\n * This setting is for whether notifications posted to this channel appear on\n * the lockscreen or not, and if so, whether they appear in a redacted form.\n *\n * @since 1.0.0\n */\n visibility?: Visibility;\n\n /**\n * Whether notifications posted to this channel should display notification\n * lights, on devices that support it.\n *\n * @since 1.0.0\n */\n lights?: boolean;\n\n /**\n * The light color for notifications posted to this channel.\n *\n * Only supported if lights are enabled on this channel and the device\n * supports it.\n *\n * Supported color formats are `#RRGGBB` and `#RRGGBBAA`.\n *\n * @since 1.0.0\n */\n lightColor?: string;\n\n /**\n * Whether notifications posted to this channel should vibrate.\n *\n * @since 1.0.0\n */\n vibration?: boolean;\n}\n\n/**\n * The importance level. For more details, see the [Android Developer Docs](https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT)\n * @since 1.0.0\n */\nexport type Importance = 1 | 2 | 3 | 4 | 5;\n\n/**\n * The notification visibility. For more details, see the [Android Developer Docs](https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PRIVATE)\n * @since 1.0.0\n */\nexport type Visibility = -1 | 0 | 1;\n\nexport interface ListChannelsResult {\n /**\n * List of all the Channels created by your app.\n *\n * @since 1.0.0\n */\n channels: Channel[];\n}\n\nexport interface PermissionStatus {\n /**\n * Permission state of receiving notifications.\n *\n * @since 1.0.0\n */\n receive: PermissionState;\n}\n\n/**\n * @deprecated Use 'Channel`.\n * @since 1.0.0\n */\nexport type NotificationChannel = Channel;\n\n/**\n * @deprecated Use `ListChannelsResult`.\n * @since 1.0.0\n */\nexport type NotificationChannelList = ListChannelsResult;\n\n/**\n * @deprecated Use `PushNotificationSchema`.\n * @since 1.0.0\n */\nexport type PushNotification = PushNotificationSchema;\n\n/**\n * @deprecated Use `ActionPerformed`.\n * @since 1.0.0\n */\nexport type PushNotificationActionPerformed = ActionPerformed;\n\n/**\n * @deprecated Use `DeliveredNotifications`.\n * @since 1.0.0\n */\nexport type PushNotificationDeliveredList = DeliveredNotifications;\n\n/**\n * @deprecated Use `Token`.\n * @since 1.0.0\n */\nexport type PushNotificationToken = Token;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,iBAAiB,GAAG,cAAc,CACtC,mBAAmB,EACnB,EAAE,CACH,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,iBAAiB,GAAG,cAAc,CACtC,mBAAmB,EACnB,EAAE,CACH,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { PushNotificationsPlugin } from './definitions';\n\nconst PushNotifications = registerPlugin<PushNotificationsPlugin>(\n 'PushNotifications',\n {},\n);\n\nexport * from './definitions';\nexport { PushNotifications };\n"]}
@@ -29,7 +29,7 @@ public class PushNotificationsHandler: NSObject, NotificationHandlerProtocol {
29
29
  }
30
30
  }
31
31
 
32
- if let optionsArray = self.plugin?.getConfigValue("presentationOptions") as? [String] {
32
+ if let optionsArray = self.plugin?.getConfig().getArray("presentationOptions") as? [String] {
33
33
  var presentationOptions = UNNotificationPresentationOptions.init()
34
34
 
35
35
  optionsArray.forEach { option in
@@ -9,7 +9,7 @@ CAP_PLUGIN(PushNotificationsPlugin, "PushNotifications",
9
9
  CAP_PLUGIN_METHOD(requestPermissions, CAPPluginReturnPromise);
10
10
  CAP_PLUGIN_METHOD(getDeliveredNotifications, CAPPluginReturnPromise);
11
11
  CAP_PLUGIN_METHOD(removeAllDeliveredNotifications, CAPPluginReturnPromise);
12
- CAP_PLUGIN_METHOD(removeAllListeners, CAPPluginReturnNone);
12
+ CAP_PLUGIN_METHOD(removeAllListeners, CAPPluginReturnPromise);
13
13
  CAP_PLUGIN_METHOD(removeDeliveredNotifications, CAPPluginReturnPromise);
14
14
  CAP_PLUGIN_METHOD(createChannel, CAPPluginReturnPromise);
15
15
  CAP_PLUGIN_METHOD(listChannels, CAPPluginReturnPromise);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/push-notifications",
3
- "version": "1.0.7",
3
+ "version": "4.0.0-beta.0",
4
4
  "description": "The Push Notifications API provides access to native push notifications.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
- "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
33
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
34
  "verify:web": "npm run build",
35
35
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
@@ -45,11 +45,11 @@
45
45
  "publish:cocoapod": "pod trunk push ./CapacitorPushNotifications.podspec --allow-warnings"
46
46
  },
47
47
  "devDependencies": {
48
- "@capacitor/android": "^3.0.0",
49
- "@capacitor/cli": "^3.0.0",
50
- "@capacitor/core": "^3.0.0",
48
+ "@capacitor/android": "next",
49
+ "@capacitor/cli": "next",
50
+ "@capacitor/core": "next",
51
51
  "@capacitor/docgen": "0.0.18",
52
- "@capacitor/ios": "^3.0.0",
52
+ "@capacitor/ios": "next",
53
53
  "@ionic/eslint-config": "^0.3.0",
54
54
  "@ionic/prettier-config": "~1.0.1",
55
55
  "@ionic/swiftlint-config": "^1.1.2",
@@ -62,7 +62,7 @@
62
62
  "typescript": "~4.1.5"
63
63
  },
64
64
  "peerDependencies": {
65
- "@capacitor/core": "^3.0.0"
65
+ "@capacitor/core": "next"
66
66
  },
67
67
  "prettier": "@ionic/prettier-config",
68
68
  "swiftlint": "@ionic/swiftlint-config",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "64df93225736e9dfad336562f5e53e5a2243052b"
83
+ "gitHead": "fd7db8285f72990522da0adc889514c9804b6dae"
84
84
  }