@capacitor-community/fcm 3.0.1 → 5.0.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/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-23-orange?style=flat-square" /></a>
16
16
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
17
17
 
18
18
  </p>
@@ -75,6 +75,7 @@ npx cap sync
75
75
  | `subscribeTo` | subscribe to fcm topic | ios/android |
76
76
  | `unsubscribeFrom` | unsubscribe from fcm topic | ios/android |
77
77
  | `getToken` | get fcm token to eventually use from a server | ios/android |
78
+ | `refreshToken` | refresh fcm token to get a new one | ios/android |
78
79
  | `deleteInstance` | remove local fcm instance completely | ios/android |
79
80
  | `setAutoInit` | enable the auto initialization of the library | ios/android |
80
81
  | `isAutoInitEnabled` | check whether auto initialization is enabled | ios/android |
@@ -105,6 +106,11 @@ FCM.getToken()
105
106
  .then((r) => alert(`Token ${r.token}`))
106
107
  .catch((err) => console.log(err));
107
108
 
109
+ // Delete the old FCM token and get a new one
110
+ FCM.refrehToken()
111
+ .then((r) => alert(`Token ${r.token}`))
112
+ .catch((err) => console.log(err));
113
+
108
114
  // Remove FCM instance
109
115
  FCM.deleteInstance()
110
116
  .then(() => alert(`Token deleted`))
@@ -190,7 +196,7 @@ Now you should be set to go. Try to run your client using `ionic cap run android
190
196
 
191
197
  This plugin will use the following project variables (defined in your app's `variables.gradle` file):
192
198
 
193
- - `$firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `23.0.5`)
199
+ - `$firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `23.1.2`)
194
200
 
195
201
  ### Prevent auto initialization
196
202
 
@@ -243,6 +249,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
243
249
  </tr>
244
250
  <tr>
245
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
+ <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
+ <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>
246
254
  </tr>
247
255
  </tbody>
248
256
  </table>
@@ -1,9 +1,9 @@
1
1
  ext {
2
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'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '23.1.2'
7
7
  }
8
8
 
9
9
  buildscript {
@@ -12,17 +12,18 @@ buildscript {
12
12
  mavenCentral()
13
13
  }
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:7.2.1'
15
+ classpath 'com.android.tools.build:gradle:8.0.0'
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 : 32
22
+ namespace "com.getcapacitor.community.fcm.fcm"
23
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
24
  defaultConfig {
24
25
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
26
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
27
  versionCode 1
27
28
  versionName "1.0"
28
29
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -38,8 +39,8 @@ android {
38
39
  }
39
40
 
40
41
  compileOptions {
41
- sourceCompatibility JavaVersion.VERSION_11
42
- targetCompatibility JavaVersion.VERSION_11
42
+ sourceCompatibility JavaVersion.VERSION_17
43
+ targetCompatibility JavaVersion.VERSION_17
43
44
  }
44
45
  }
45
46
 
@@ -1,5 +1,4 @@
1
1
 
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.getcapacitor.community.fcm.fcm">
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
4
3
  </manifest>
5
4
 
@@ -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);
@@ -75,12 +85,12 @@ public class FCMPlugin extends Plugin {
75
85
  @PluginMethod()
76
86
  public void refreshToken(final PluginCall call) {
77
87
  FirebaseMessaging.getInstance().deleteToken();
78
- FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult -> {
88
+ FirebaseMessaging.getInstance().getToken().addOnCompleteListener(getActivity(), tokenResult -> {
79
89
  JSObject data = new JSObject();
80
- data.put("token", instanceIdResult.getToken());
90
+ data.put("token", tokenResult.getResult());
81
91
  call.resolve(data);
82
92
  });
83
- FirebaseInstallations.getInstance().getId().addOnFailureListener(e -> call.reject("Failed to get instance FirebaseID", e));
93
+ FirebaseMessaging.getInstance().getToken().addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e));
84
94
  }
85
95
 
86
96
  @PluginMethod()
@@ -82,6 +82,16 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
82
82
  }
83
83
 
84
84
  @objc func refreshToken(_ call: CAPPluginCall) {
85
+ // Delete FCM Token on Firebase
86
+ FirebaseMessaging.Messaging.messaging().deleteData { error in
87
+ guard let error = error else {
88
+ print("Delete FCMToken successful!")
89
+ return
90
+ }
91
+ call.reject("Delete FCMToken failed", error.localizedDescription)
92
+ print("Delete FCMToken failed: \(String(describing: error.localizedDescription))!")
93
+ }
94
+
85
95
  Messaging.messaging().token { token, error in
86
96
  if let error = error {
87
97
  print("Error fetching FCM registration token: \(error)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/fcm",
3
- "version": "3.0.1",
3
+ "version": "5.0.0",
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",
@@ -51,10 +51,10 @@
51
51
  "contributors:gen": "all-contributors generate"
52
52
  },
53
53
  "devDependencies": {
54
- "@capacitor/android": "^4.0.0",
55
- "@capacitor/core": "^4.0.0",
54
+ "@capacitor/android": "next",
55
+ "@capacitor/core": "next",
56
56
  "@capacitor/docgen": "^0.0.18",
57
- "@capacitor/ios": "^4.0.0",
57
+ "@capacitor/ios": "next",
58
58
  "@ionic/eslint-config": "^0.3.0",
59
59
  "@ionic/prettier-config": "^1.0.1",
60
60
  "@ionic/swiftlint-config": "^1.1.2",
@@ -69,7 +69,7 @@
69
69
  "typescript": "~4.1.5"
70
70
  },
71
71
  "peerDependencies": {
72
- "@capacitor/core": "^4.0.0"
72
+ "@capacitor/core": "next"
73
73
  },
74
74
  "prettier": "@ionic/prettier-config",
75
75
  "swiftlint": "@ionic/swiftlint-config",
package/CHANGELOG.md DELETED
@@ -1,112 +0,0 @@
1
- # Changelog
2
-
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
-
5
- ### [3.0.1](https://github.com/capacitor-community/fcm/compare/v3.0.0...v3.0.1) (2022-11-08)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * add sponsor ([e2270f6](https://github.com/capacitor-community/fcm/commit/e2270f607287fa1440c5150de57e93f4d52f42d6))
11
- * **android:** update firebaseMessagingVersion default value ([445b8ac](https://github.com/capacitor-community/fcm/commit/445b8ac805daf3ac52c3ccf0e4b89ed0e93a012d))
12
- * readme ([1cbc83c](https://github.com/capacitor-community/fcm/commit/1cbc83c7825395ea7310814fa70ed1fd0ca809bb))
13
-
14
- ### [2.0.2](https://github.com/capacitor-community/fcm/compare/v2.0.1...v2.0.2) (2021-10-04)
15
-
16
- ### [2.0.1](https://github.com/capacitor-community/fcm/compare/v2.0.0...v2.0.1) (2021-09-13)
17
-
18
- ## [2.0.0](https://github.com/capacitor-community/fcm/compare/v1.1.2...v2.0.0) (2021-06-14)
19
-
20
-
21
- ### Bug Fixes
22
-
23
- * upgrade to firebase 8 and fix plugin for capacitor 3 ([3317a8e](https://github.com/capacitor-community/fcm/commit/3317a8e9824b2dbf7d179410a31d7494669f0c51))
24
-
25
- ### [1.1.2](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.2) (2021-06-11)
26
-
27
-
28
- ### Bug Fixes
29
-
30
- * maintenance badge ([d91eff2](https://github.com/capacitor-community/fcm/commit/d91eff2c32d66bb4a43927b8026d66490098f656))
31
- * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981))
32
- * podspec ([a3fa50a](https://github.com/capacitor-community/fcm/commit/a3fa50ae039f6a5680d7dd5094675e6ee5a436eb))
33
- * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b))
34
-
35
- ### [1.1.1](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.1) (2021-05-23)
36
-
37
-
38
- ### Bug Fixes
39
-
40
- * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981))
41
- * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b))
42
-
43
- ## [1.1.0](https://github.com/capacitor-community/fcm/compare/v1.0.8...v1.1.0) (2021-02-15)
44
-
45
- ### [1.0.8](https://github.com/capacitor-community/fcm/compare/v1.0.7...v1.0.8) (2020-07-11)
46
-
47
- ### Bug Fixes
48
-
49
- - **ios:** get token using instanceID ([f62d33c](https://github.com/capacitor-community/fcm/commit/f62d33cb77e9ce071e2effa71063a740efd9d406))
50
-
51
- ### [1.0.7](https://github.com/capacitor-community/fcm/compare/v1.0.6...v1.0.7) (2020-07-02)
52
-
53
- - use 2.0.0 instead of latest in package.json
54
-
55
- ### [1.0.6](https://github.com/capacitor-community/fcm/compare/v1.0.5...v1.0.6) (2020-06-29)
56
-
57
- ### Features
58
-
59
- - add example ([1304c79](https://github.com/capacitor-community/fcm/commit/1304c79cf60c772589f2421ff292eac77480887b))
60
-
61
- ### Bug Fixes
62
-
63
- - **android:** java path ([70a0c9a](https://github.com/capacitor-community/fcm/commit/70a0c9a952f19210e6c237fe9489ddeb3562acc2))
64
-
65
- ### [1.0.5](https://github.com/capacitor-community/fcm/compare/v1.0.4...v1.0.5) (2020-06-29)
66
-
67
- ### Bug Fixes
68
-
69
- - **android:** refactoring to match community standards. closes [#43](https://github.com/capacitor-community/fcm/issues/43) [#44](https://github.com/capacitor-community/fcm/issues/44) ([11761b8](https://github.com/capacitor-community/fcm/commit/11761b8f024422f89288f940c8a6a146b3ff9a5e))
70
-
71
- ### [1.0.4](https://github.com/capacitor-community/fcm/compare/v1.0.3...v1.0.4) (2020-06-27)
72
-
73
- ### Bug Fixes
74
-
75
- - contributor links ([73aa017](https://github.com/capacitor-community/fcm/commit/73aa01789a2356711542503c2b864653855c8a50))
76
-
77
- ### [1.0.3](https://github.com/capacitor-community/fcm/compare/v1.0.2...v1.0.3) (2020-06-27)
78
-
79
- ### [1.0.2](https://github.com/capacitor-community/fcm/compare/v1.0.1...v1.0.2) (2020-06-27)
80
-
81
- ### Bug Fixes
82
-
83
- - podspec name ([1ccad9b](https://github.com/capacitor-community/fcm/commit/1ccad9b45a9462b5315f0e32612696a32dcbecd2))
84
-
85
- ### [1.0.1](https://github.com/capacitor-community/fcm/compare/v1.0.0...v1.0.1) (2020-06-27)
86
-
87
- ### Bug Fixes
88
-
89
- - **ios:** Fixing wrong Firebase dependency ([6e96be0](https://github.com/capacitor-community/fcm/commit/6e96be0388e67c28c389debd26a11ed3b145e4af))
90
-
91
- ## 1.0.0 (2020-06-27)
92
-
93
- ### Features
94
-
95
- - **README:** add androidy notes ([9042cba](https://github.com/capacitor-community/fcm/commit/9042cba2bf1182bb0542177ba8fd1303b492009b))
96
- - add android support ([f3caba1](https://github.com/capacitor-community/fcm/commit/f3caba115a593a9fbb918ee63c2427c3ce5d0870))
97
- - **FCM:** add subscribe to topic ([6f0f88d](https://github.com/capacitor-community/fcm/commit/6f0f88db173a726ae4b412bfe9b0333f296ed327))
98
- - **ios:** add getToken and clean project to be publish ([ddec39b](https://github.com/capacitor-community/fcm/commit/ddec39b666e3338a5dd73b39c33510c2eb84c4e7))
99
- - add README ([863cb25](https://github.com/capacitor-community/fcm/commit/863cb25361fb7ecd8dcd63c64f7181f9d7f5b72f))
100
- - add unsubscribe from topic ([a6a3dee](https://github.com/capacitor-community/fcm/commit/a6a3dee09b5b2faaca01e50fc2cedb1992df41d5))
101
-
102
- ### Bug Fixes
103
-
104
- - **android:** add app compat ([5709b1d](https://github.com/capacitor-community/fcm/commit/5709b1dadbd62d1f62b0be86bb1229e9f4e9bc5f))
105
- - **android:** add deps ([9927aee](https://github.com/capacitor-community/fcm/commit/9927aeee0637945520bea03b69f609a0806b5767))
106
- - **android:** cap implementation ([b394973](https://github.com/capacitor-community/fcm/commit/b3949730c7ff27afb3a5f4a94dce60360590acde))
107
- - **android:** package name ([f148a20](https://github.com/capacitor-community/fcm/commit/f148a203551e457a89eed8fedaf24c8fe925b88a))
108
- - **ios:** notifications were not being delivered on a freshed app install ([f3d10a5](https://github.com/capacitor-community/fcm/commit/f3d10a59a866c0c92cbfd91a3a400c6126de03cb))
109
- - **ios:** notifications were not being delivered on a freshed app install ([3205224](https://github.com/capacitor-community/fcm/commit/3205224885465a186a830c9679f4b3ce5abdb321))
110
- - **ios:** plugin not working on Case-Sensitive file system ([1deb869](https://github.com/capacitor-community/fcm/commit/1deb86951dc23a337a7910f5df1bba7e48005d72))
111
- - **podspec:** add firebase back ([933ddbe](https://github.com/capacitor-community/fcm/commit/933ddbed2b168e2552aae7138914e7ed54d59492))
112
- - **README:** add sample app link ([ef67512](https://github.com/capacitor-community/fcm/commit/ef67512f94ffb317464006b1eb71a619a9e45079))
Binary file
Binary file
Binary file
Binary file