@capacitor/push-notifications 1.0.7 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
6
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)
7
15
 
8
16
  **Note:** Version bump only for package @capacitor/push-notifications
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/push-notifications",
3
- "version": "1.0.7",
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",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "64df93225736e9dfad336562f5e53e5a2243052b"
83
+ "gitHead": "e5b333320426ee120d4504c68c02bd5538b21c51"
84
84
  }