@capacitor/push-notifications 1.0.3 → 1.0.8
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 +49 -0
- package/CapacitorPushNotifications.podspec +3 -3
- package/README.md +51 -4
- package/android/src/main/java/com/capacitorjs/plugins/pushnotifications/NotificationChannelManager.java +18 -3
- package/dist/docs.json +6 -6
- package/dist/esm/definitions.d.ts +8 -0
- package/dist/plugin.js +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,55 @@
|
|
|
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
|
+
## [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)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @capacitor/push-notifications
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [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)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @capacitor/push-notifications
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.0.6](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.5...@capacitor/push-notifications@1.0.6) (2021-10-14)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [1.0.5](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.4...@capacitor/push-notifications@1.0.5) (2021-10-13)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## [1.0.4](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.3...@capacitor/push-notifications@1.0.4) (2021-09-01)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* **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))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
## [1.0.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/push-notifications@1.0.2...@capacitor/push-notifications@1.0.3) (2021-07-07)
|
|
7
56
|
|
|
8
57
|
**Note:** Version bump only for package @capacitor/push-notifications
|
|
@@ -7,10 +7,10 @@ Pod::Spec.new do |s|
|
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|
|
10
|
-
s.homepage =
|
|
10
|
+
s.homepage = 'https://capacitorjs.com'
|
|
11
11
|
s.author = package['author']
|
|
12
|
-
s.source = { :git => package['
|
|
13
|
-
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
12
|
+
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
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
14
|
s.ios.deployment_target = '12.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
package/README.md
CHANGED
|
@@ -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>
|
|
@@ -122,10 +165,10 @@ On Android, there are various system and app states that can affect the delivery
|
|
|
122
165
|
* [`listChannels()`](#listchannels)
|
|
123
166
|
* [`checkPermissions()`](#checkpermissions)
|
|
124
167
|
* [`requestPermissions()`](#requestpermissions)
|
|
125
|
-
* [`addListener('registration', ...)`](#addlistenerregistration
|
|
126
|
-
* [`addListener('registrationError', ...)`](#addlistenerregistrationerror
|
|
127
|
-
* [`addListener('pushNotificationReceived', ...)`](#addlistenerpushnotificationreceived
|
|
128
|
-
* [`addListener('pushNotificationActionPerformed', ...)`](#addlistenerpushnotificationactionperformed
|
|
168
|
+
* [`addListener('registration', ...)`](#addlistenerregistration)
|
|
169
|
+
* [`addListener('registrationError', ...)`](#addlistenerregistrationerror)
|
|
170
|
+
* [`addListener('pushNotificationReceived', ...)`](#addlistenerpushnotificationreceived)
|
|
171
|
+
* [`addListener('pushNotificationActionPerformed', ...)`](#addlistenerpushnotificationactionperformed)
|
|
129
172
|
* [`removeAllListeners()`](#removealllisteners)
|
|
130
173
|
* [Interfaces](#interfaces)
|
|
131
174
|
* [Type Aliases](#type-aliases)
|
|
@@ -475,11 +518,15 @@ Remove all native listeners for this plugin.
|
|
|
475
518
|
|
|
476
519
|
#### Importance
|
|
477
520
|
|
|
521
|
+
The importance level. For more details, see the [Android Developer Docs](https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT)
|
|
522
|
+
|
|
478
523
|
<code>1 | 2 | 3 | 4 | 5</code>
|
|
479
524
|
|
|
480
525
|
|
|
481
526
|
#### Visibility
|
|
482
527
|
|
|
528
|
+
The notification visibility. For more details, see the [Android Developer Docs](https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PRIVATE)
|
|
529
|
+
|
|
483
530
|
<code>-1 | 0 | 1</code>
|
|
484
531
|
|
|
485
532
|
|
|
@@ -38,11 +38,26 @@ public class NotificationChannelManager {
|
|
|
38
38
|
public void createChannel(PluginCall call) {
|
|
39
39
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
40
40
|
JSObject channel = new JSObject();
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (call.getString(CHANNEL_ID) != null) {
|
|
42
|
+
channel.put(CHANNEL_ID, call.getString(CHANNEL_ID));
|
|
43
|
+
} else {
|
|
44
|
+
call.reject("Channel missing identifier");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (call.getString(CHANNEL_NAME) != null) {
|
|
48
|
+
channel.put(CHANNEL_NAME, call.getString(CHANNEL_NAME));
|
|
49
|
+
} else {
|
|
50
|
+
call.reject("Channel missing name");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
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
|
+
}
|
|
43
59
|
channel.put(CHANNEL_DESCRIPTION, call.getString(CHANNEL_DESCRIPTION, ""));
|
|
44
60
|
channel.put(CHANNEL_VISIBILITY, call.getInt(CHANNEL_VISIBILITY, NotificationCompat.VISIBILITY_PUBLIC));
|
|
45
|
-
channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE));
|
|
46
61
|
channel.put(CHANNEL_SOUND, call.getString(CHANNEL_SOUND, null));
|
|
47
62
|
channel.put(CHANNEL_VIBRATE, call.getBoolean(CHANNEL_VIBRATE, false));
|
|
48
63
|
channel.put(CHANNEL_USE_LIGHTS, call.getBoolean(CHANNEL_USE_LIGHTS, false));
|
package/dist/docs.json
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"PluginListenerHandle",
|
|
200
200
|
"Token"
|
|
201
201
|
],
|
|
202
|
-
"slug": "addlistenerregistration
|
|
202
|
+
"slug": "addlistenerregistration"
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
205
|
"name": "addListener",
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
"complexTypes": [
|
|
228
228
|
"PluginListenerHandle"
|
|
229
229
|
],
|
|
230
|
-
"slug": "addlistenerregistrationerror
|
|
230
|
+
"slug": "addlistenerregistrationerror"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"name": "addListener",
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
"PluginListenerHandle",
|
|
257
257
|
"PushNotificationSchema"
|
|
258
258
|
],
|
|
259
|
-
"slug": "addlistenerpushnotificationreceived
|
|
259
|
+
"slug": "addlistenerpushnotificationreceived"
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
262
|
"name": "addListener",
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"PluginListenerHandle",
|
|
286
286
|
"ActionPerformed"
|
|
287
287
|
],
|
|
288
|
-
"slug": "addlistenerpushnotificationactionperformed
|
|
288
|
+
"slug": "addlistenerpushnotificationactionperformed"
|
|
289
289
|
},
|
|
290
290
|
{
|
|
291
291
|
"name": "removeAllListeners",
|
|
@@ -735,7 +735,7 @@
|
|
|
735
735
|
{
|
|
736
736
|
"name": "Importance",
|
|
737
737
|
"slug": "importance",
|
|
738
|
-
"docs": "",
|
|
738
|
+
"docs": "The importance level. For more details, see the [Android Developer Docs](https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT)",
|
|
739
739
|
"types": [
|
|
740
740
|
{
|
|
741
741
|
"text": "1",
|
|
@@ -762,7 +762,7 @@
|
|
|
762
762
|
{
|
|
763
763
|
"name": "Visibility",
|
|
764
764
|
"slug": "visibility",
|
|
765
|
-
"docs": "",
|
|
765
|
+
"docs": "The notification visibility. For more details, see the [Android Developer Docs](https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PRIVATE)",
|
|
766
766
|
"types": [
|
|
767
767
|
{
|
|
768
768
|
"text": "-1",
|
|
@@ -325,7 +325,15 @@ export interface Channel {
|
|
|
325
325
|
*/
|
|
326
326
|
vibration?: boolean;
|
|
327
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* The importance level. For more details, see the [Android Developer Docs](https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT)
|
|
330
|
+
* @since 1.0.0
|
|
331
|
+
*/
|
|
328
332
|
export declare type Importance = 1 | 2 | 3 | 4 | 5;
|
|
333
|
+
/**
|
|
334
|
+
* The notification visibility. For more details, see the [Android Developer Docs](https://developer.android.com/reference/androidx/core/app/NotificationCompat#VISIBILITY_PRIVATE)
|
|
335
|
+
* @since 1.0.0
|
|
336
|
+
*/
|
|
329
337
|
export declare type Visibility = -1 | 0 | 1;
|
|
330
338
|
export interface ListChannelsResult {
|
|
331
339
|
/**
|
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/push-notifications",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
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",
|
|
36
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint --
|
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
37
|
"eslint": "eslint . --ext ts",
|
|
38
38
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
39
|
"swiftlint": "node-swiftlint",
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
42
42
|
"clean": "rimraf ./dist",
|
|
43
43
|
"watch": "tsc --watch",
|
|
44
|
-
"prepublishOnly": "npm run build"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"publish:cocoapod": "pod trunk push ./CapacitorPushNotifications.podspec --allow-warnings"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@capacitor/android": "^3.0.0",
|
|
48
49
|
"@capacitor/cli": "^3.0.0",
|
|
49
50
|
"@capacitor/core": "^3.0.0",
|
|
50
|
-
"@capacitor/docgen": "0.0.
|
|
51
|
+
"@capacitor/docgen": "0.0.18",
|
|
51
52
|
"@capacitor/ios": "^3.0.0",
|
|
52
53
|
"@ionic/eslint-config": "^0.3.0",
|
|
53
54
|
"@ionic/prettier-config": "~1.0.1",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"publishConfig": {
|
|
80
81
|
"access": "public"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "e5b333320426ee120d4504c68c02bd5538b21c51"
|
|
83
84
|
}
|