@capacitor-community/fcm 5.0.1 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
9
|
+
<img src="https://img.shields.io/maintenance/yes/2024?style=flat-square" />
|
|
10
10
|
<a href="https://www.npmjs.com/package/@capacitor-community/fcm"><img src="https://img.shields.io/npm/l/@capacitor-community/fcm?style=flat-square" /></a>
|
|
11
11
|
<br>
|
|
12
12
|
<a href="https://www.npmjs.com/package/@capacitor-community/fcm"><img src="https://img.shields.io/npm/dw/@capacitor-community/fcm?style=flat-square" /></a>
|
|
13
13
|
<a href="https://www.npmjs.com/package/@capacitor-community/fcm"><img src="https://img.shields.io/npm/v/@capacitor-community/fcm?style=flat-square" /></a>
|
|
14
14
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
15
|
-
<a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-
|
|
15
|
+
<a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-25-orange?style=flat-square" /></a>
|
|
16
16
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
17
17
|
|
|
18
18
|
</p>
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
<table>
|
|
23
23
|
<tr>
|
|
24
24
|
<td align="center">
|
|
25
|
-
<a href="https://
|
|
26
|
-
<img src="https://
|
|
25
|
+
<a href="https://chatness.ai">
|
|
26
|
+
<img src="https://cdn.chatness.ai/images/logo-white-symbol.png" width="40" />
|
|
27
27
|
</a>
|
|
28
28
|
</td>
|
|
29
29
|
<td>
|
|
30
|
-
<a href="https://
|
|
31
|
-
|
|
30
|
+
<a href="https://chatness.ai">
|
|
31
|
+
Chatness AI
|
|
32
32
|
</a>
|
|
33
33
|
</td>
|
|
34
34
|
</tr>
|
|
@@ -83,8 +83,8 @@ npx cap sync
|
|
|
83
83
|
## Usage
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
import { FCM } from
|
|
87
|
-
import { PushNotifications } from
|
|
86
|
+
import { FCM } from '@capacitor-community/fcm';
|
|
87
|
+
import { PushNotifications } from '@capacitor/push-notifications';
|
|
88
88
|
|
|
89
89
|
// external required step
|
|
90
90
|
// register for push
|
|
@@ -92,36 +92,36 @@ await PushNotifications.requestPermissions();
|
|
|
92
92
|
await PushNotifications.register();
|
|
93
93
|
|
|
94
94
|
// now you can subscribe to a specific topic
|
|
95
|
-
FCM.subscribeTo({ topic:
|
|
96
|
-
.then(
|
|
97
|
-
.catch(
|
|
95
|
+
FCM.subscribeTo({ topic: 'test' })
|
|
96
|
+
.then(r => alert(`subscribed to topic`))
|
|
97
|
+
.catch(err => console.log(err));
|
|
98
98
|
|
|
99
99
|
// Unsubscribe from a specific topic
|
|
100
|
-
FCM.unsubscribeFrom({ topic:
|
|
100
|
+
FCM.unsubscribeFrom({ topic: 'test' })
|
|
101
101
|
.then(() => alert(`unsubscribed from topic`))
|
|
102
|
-
.catch(
|
|
102
|
+
.catch(err => console.log(err));
|
|
103
103
|
|
|
104
|
-
// Get FCM token instead the APN one returned by Capacitor
|
|
104
|
+
// Get FCM token instead of the APN one returned by Capacitor
|
|
105
105
|
FCM.getToken()
|
|
106
|
-
.then(
|
|
107
|
-
.catch(
|
|
106
|
+
.then(r => alert(`Token ${r.token}`))
|
|
107
|
+
.catch(err => console.log(err));
|
|
108
108
|
|
|
109
109
|
// Delete the old FCM token and get a new one
|
|
110
|
-
FCM.
|
|
111
|
-
.then(
|
|
112
|
-
.catch(
|
|
110
|
+
FCM.refreshToken()
|
|
111
|
+
.then(r => alert(`Token ${r.token}`))
|
|
112
|
+
.catch(err => console.log(err));
|
|
113
113
|
|
|
114
114
|
// Remove FCM instance
|
|
115
115
|
FCM.deleteInstance()
|
|
116
116
|
.then(() => alert(`Token deleted`))
|
|
117
|
-
.catch(
|
|
117
|
+
.catch(err => console.log(err));
|
|
118
118
|
|
|
119
119
|
// Enable the auto initialization of the library
|
|
120
120
|
FCM.setAutoInit({ enabled: true }).then(() => alert(`Auto init enabled`));
|
|
121
121
|
|
|
122
122
|
// Check the auto initialization status
|
|
123
|
-
FCM.isAutoInitEnabled().then(
|
|
124
|
-
console.log(
|
|
123
|
+
FCM.isAutoInitEnabled().then(r => {
|
|
124
|
+
console.log('Auto init is ' + (r.enabled ? 'enabled' : 'disabled'));
|
|
125
125
|
});
|
|
126
126
|
```
|
|
127
127
|
|
|
@@ -220,7 +220,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
220
220
|
<table>
|
|
221
221
|
<tbody>
|
|
222
222
|
<tr>
|
|
223
|
-
<td align="center" valign="top" width="20%"><a href="https://twitter.com/stewones"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt="
|
|
223
|
+
<td align="center" valign="top" width="20%"><a href="https://twitter.com/stewones"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt="stewones"/><br /><sub><b>stewones</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=stewones" title="Code">💻</a> <a href="https://github.com/capacitor-community/fcm/commits?author=stewones" title="Documentation">📖</a></td>
|
|
224
224
|
<td align="center" valign="top" width="20%"><a href="https://github.com/danielprrazevedo"><img src="https://avatars2.githubusercontent.com/u/20153661?v=4?s=75" width="75px;" alt="Daniel Pereira"/><br /><sub><b>Daniel Pereira</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=danielprrazevedo" title="Code">💻</a> <a href="https://github.com/capacitor-community/fcm/commits?author=danielprrazevedo" title="Documentation">📖</a></td>
|
|
225
225
|
<td align="center" valign="top" width="20%"><a href="http://priyankpatel.io/"><img src="https://avatars3.githubusercontent.com/u/5585797?v=4?s=75" width="75px;" alt="Priyank Patel"/><br /><sub><b>Priyank Patel</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=priyankpat" title="Code">💻</a></td>
|
|
226
226
|
<td align="center" valign="top" width="20%"><a href="http://fuubar.wordpress.com/"><img src="https://avatars1.githubusercontent.com/u/1230033?v=4?s=75" width="75px;" alt="Nikolas"/><br /><sub><b>Nikolas</b></sub></a><br /><a href="#maintenance-nikoskip" title="Maintenance">🚧</a></td>
|
|
@@ -251,6 +251,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
251
251
|
<td align="center" valign="top" width="20%"><a href="http://www.jcesarmobile.com/"><img src="https://avatars.githubusercontent.com/u/1637892?v=4?s=75" width="75px;" alt="jcesarmobile"/><br /><sub><b>jcesarmobile</b></sub></a><br /><a href="#question-jcesarmobile" title="Answering Questions">💬</a> <a href="https://github.com/capacitor-community/fcm/commits?author=jcesarmobile" title="Documentation">📖</a> <a href="#maintenance-jcesarmobile" title="Maintenance">🚧</a></td>
|
|
252
252
|
<td align="center" valign="top" width="20%"><a href="https://github.com/ramikhafagi96"><img src="https://avatars.githubusercontent.com/u/38646828?v=4?s=75" width="75px;" alt="Rami Khafagi"/><br /><sub><b>Rami Khafagi</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=ramikhafagi96" title="Code">💻</a></td>
|
|
253
253
|
<td align="center" valign="top" width="20%"><a href="https://github.com/bipoza"><img src="https://avatars.githubusercontent.com/u/26112509?v=4?s=75" width="75px;" alt="Bittor Poza"/><br /><sub><b>Bittor Poza</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=bipoza" title="Code">💻</a></td>
|
|
254
|
+
<td align="center" valign="top" width="20%"><a href="https://github.com/Vishal-Isharani"><img src="https://avatars.githubusercontent.com/u/10386581?v=4?s=75" width="75px;" alt="Vishal Isharani"/><br /><sub><b>Vishal Isharani</b></sub></a><br /><a href="#maintenance-Vishal-Isharani" title="Maintenance">🚧</a></td>
|
|
255
|
+
<td align="center" valign="top" width="20%"><a href="https://github.com/kashz"><img src="https://avatars.githubusercontent.com/u/12661101?v=4?s=75" width="75px;" alt="Shunta KARASAWA"/><br /><sub><b>Shunta KARASAWA</b></sub></a><br /><a href="#maintenance-kashz" title="Maintenance">🚧</a></td>
|
|
254
256
|
</tr>
|
|
255
257
|
</tbody>
|
|
256
258
|
</table>
|
|
@@ -84,13 +84,13 @@ public class FCMPlugin extends Plugin {
|
|
|
84
84
|
|
|
85
85
|
@PluginMethod()
|
|
86
86
|
public void refreshToken(final PluginCall call) {
|
|
87
|
-
FirebaseMessaging.getInstance().deleteToken()
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
FirebaseMessaging.getInstance().deleteToken().addOnCompleteListener((result) -> {
|
|
88
|
+
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(getActivity(), tokenResult -> {
|
|
89
|
+
JSObject data = new JSObject();
|
|
90
|
+
data.put("token", tokenResult.getResult());
|
|
91
|
+
call.resolve(data);
|
|
92
|
+
}).addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e));
|
|
93
|
+
}).addOnFailureListener(e -> call.reject("Failed to delete FCM registration token", e));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
@PluginMethod()
|
|
@@ -7,7 +7,9 @@ CAP_PLUGIN(FCMPlugin, "FCM",
|
|
|
7
7
|
CAP_PLUGIN_METHOD(subscribeTo, CAPPluginReturnPromise);
|
|
8
8
|
CAP_PLUGIN_METHOD(unsubscribeFrom, CAPPluginReturnPromise);
|
|
9
9
|
CAP_PLUGIN_METHOD(getToken, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(refreshToken, CAPPluginReturnPromise);
|
|
10
11
|
CAP_PLUGIN_METHOD(deleteInstance, CAPPluginReturnPromise);
|
|
11
12
|
CAP_PLUGIN_METHOD(setAutoInit, CAPPluginReturnPromise);
|
|
12
13
|
CAP_PLUGIN_METHOD(isAutoInitEnabled, CAPPluginReturnPromise);
|
|
14
|
+
CAP_PLUGIN_METHOD(refreshToken, CAPPluginReturnPromise);
|
|
13
15
|
)
|