@capacitor-community/fcm 3.0.1 → 3.0.2

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
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.0.2](https://github.com/capacitor-community/fcm/compare/v3.0.1...v3.0.2) (2022-12-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * check if task is successful before accessing result to avoid crashes ([0304daa](https://github.com/capacitor-community/fcm/commit/0304daa54d25305a166661d9040bd7cb107261da))
11
+
5
12
  ### [3.0.1](https://github.com/capacitor-community/fcm/compare/v3.0.0...v3.0.1) (2022-11-08)
6
13
 
7
14
 
package/README.md CHANGED
@@ -12,7 +12,7 @@
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-21-orange?style=flat-square" /></a>
15
+ <a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-22-orange?style=flat-square" /></a>
16
16
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
17
17
 
18
18
  </p>
@@ -243,6 +243,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
243
243
  </tr>
244
244
  <tr>
245
245
  <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>
246
+ <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>
246
247
  </tr>
247
248
  </tbody>
248
249
  </table>
@@ -1,5 +1,7 @@
1
1
  package com.getcapacitor.community.fcm;
2
2
 
3
+ import android.util.Log;
4
+
3
5
  import com.getcapacitor.JSObject;
4
6
  import com.getcapacitor.Plugin;
5
7
  import com.getcapacitor.PluginCall;
@@ -19,6 +21,8 @@ import com.google.firebase.messaging.FirebaseMessaging;
19
21
  )
20
22
  public class FCMPlugin extends Plugin {
21
23
 
24
+ public static final String TAG = "FirebaseMessaging";
25
+
22
26
  @PluginMethod()
23
27
  public void subscribeTo(final PluginCall call) {
24
28
  final String topicName = call.getString("topic");
@@ -64,6 +68,12 @@ public class FCMPlugin extends Plugin {
64
68
  @PluginMethod()
65
69
  public void getToken(final PluginCall call) {
66
70
  FirebaseMessaging.getInstance().getToken().addOnCompleteListener(getActivity(), tokenResult -> {
71
+ if (!tokenResult.isSuccessful()) {
72
+ Exception exception = tokenResult.getException();
73
+ Log.w(TAG, "Fetching FCM registration token failed", exception);
74
+ call.errorCallback(exception.getLocalizedMessage());
75
+ return;
76
+ }
67
77
  JSObject data = new JSObject();
68
78
  data.put("token", tokenResult.getResult());
69
79
  call.resolve(data);
@@ -80,6 +90,7 @@ public class FCMPlugin extends Plugin {
80
90
  data.put("token", instanceIdResult.getToken());
81
91
  call.resolve(data);
82
92
  });
93
+
83
94
  FirebaseInstallations.getInstance().getId().addOnFailureListener(e -> call.reject("Failed to get instance FirebaseID", e));
84
95
  }
85
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/fcm",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Enable Firebase Cloud Messaging features for Capacitor apps",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",