@capacitor-community/fcm 3.0.2 → 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-22-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
 
@@ -244,6 +250,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
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>
246
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>
247
254
  </tr>
248
255
  </tbody>
249
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
 
@@ -85,13 +85,12 @@ public class FCMPlugin extends Plugin {
85
85
  @PluginMethod()
86
86
  public void refreshToken(final PluginCall call) {
87
87
  FirebaseMessaging.getInstance().deleteToken();
88
- FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult -> {
88
+ FirebaseMessaging.getInstance().getToken().addOnCompleteListener(getActivity(), tokenResult -> {
89
89
  JSObject data = new JSObject();
90
- data.put("token", instanceIdResult.getToken());
90
+ data.put("token", tokenResult.getResult());
91
91
  call.resolve(data);
92
92
  });
93
-
94
- 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));
95
94
  }
96
95
 
97
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.2",
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,119 +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.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
-
12
- ### [3.0.1](https://github.com/capacitor-community/fcm/compare/v3.0.0...v3.0.1) (2022-11-08)
13
-
14
-
15
- ### Bug Fixes
16
-
17
- * add sponsor ([e2270f6](https://github.com/capacitor-community/fcm/commit/e2270f607287fa1440c5150de57e93f4d52f42d6))
18
- * **android:** update firebaseMessagingVersion default value ([445b8ac](https://github.com/capacitor-community/fcm/commit/445b8ac805daf3ac52c3ccf0e4b89ed0e93a012d))
19
- * readme ([1cbc83c](https://github.com/capacitor-community/fcm/commit/1cbc83c7825395ea7310814fa70ed1fd0ca809bb))
20
-
21
- ### [2.0.2](https://github.com/capacitor-community/fcm/compare/v2.0.1...v2.0.2) (2021-10-04)
22
-
23
- ### [2.0.1](https://github.com/capacitor-community/fcm/compare/v2.0.0...v2.0.1) (2021-09-13)
24
-
25
- ## [2.0.0](https://github.com/capacitor-community/fcm/compare/v1.1.2...v2.0.0) (2021-06-14)
26
-
27
-
28
- ### Bug Fixes
29
-
30
- * upgrade to firebase 8 and fix plugin for capacitor 3 ([3317a8e](https://github.com/capacitor-community/fcm/commit/3317a8e9824b2dbf7d179410a31d7494669f0c51))
31
-
32
- ### [1.1.2](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.2) (2021-06-11)
33
-
34
-
35
- ### Bug Fixes
36
-
37
- * maintenance badge ([d91eff2](https://github.com/capacitor-community/fcm/commit/d91eff2c32d66bb4a43927b8026d66490098f656))
38
- * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981))
39
- * podspec ([a3fa50a](https://github.com/capacitor-community/fcm/commit/a3fa50ae039f6a5680d7dd5094675e6ee5a436eb))
40
- * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b))
41
-
42
- ### [1.1.1](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.1) (2021-05-23)
43
-
44
-
45
- ### Bug Fixes
46
-
47
- * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981))
48
- * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b))
49
-
50
- ## [1.1.0](https://github.com/capacitor-community/fcm/compare/v1.0.8...v1.1.0) (2021-02-15)
51
-
52
- ### [1.0.8](https://github.com/capacitor-community/fcm/compare/v1.0.7...v1.0.8) (2020-07-11)
53
-
54
- ### Bug Fixes
55
-
56
- - **ios:** get token using instanceID ([f62d33c](https://github.com/capacitor-community/fcm/commit/f62d33cb77e9ce071e2effa71063a740efd9d406))
57
-
58
- ### [1.0.7](https://github.com/capacitor-community/fcm/compare/v1.0.6...v1.0.7) (2020-07-02)
59
-
60
- - use 2.0.0 instead of latest in package.json
61
-
62
- ### [1.0.6](https://github.com/capacitor-community/fcm/compare/v1.0.5...v1.0.6) (2020-06-29)
63
-
64
- ### Features
65
-
66
- - add example ([1304c79](https://github.com/capacitor-community/fcm/commit/1304c79cf60c772589f2421ff292eac77480887b))
67
-
68
- ### Bug Fixes
69
-
70
- - **android:** java path ([70a0c9a](https://github.com/capacitor-community/fcm/commit/70a0c9a952f19210e6c237fe9489ddeb3562acc2))
71
-
72
- ### [1.0.5](https://github.com/capacitor-community/fcm/compare/v1.0.4...v1.0.5) (2020-06-29)
73
-
74
- ### Bug Fixes
75
-
76
- - **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))
77
-
78
- ### [1.0.4](https://github.com/capacitor-community/fcm/compare/v1.0.3...v1.0.4) (2020-06-27)
79
-
80
- ### Bug Fixes
81
-
82
- - contributor links ([73aa017](https://github.com/capacitor-community/fcm/commit/73aa01789a2356711542503c2b864653855c8a50))
83
-
84
- ### [1.0.3](https://github.com/capacitor-community/fcm/compare/v1.0.2...v1.0.3) (2020-06-27)
85
-
86
- ### [1.0.2](https://github.com/capacitor-community/fcm/compare/v1.0.1...v1.0.2) (2020-06-27)
87
-
88
- ### Bug Fixes
89
-
90
- - podspec name ([1ccad9b](https://github.com/capacitor-community/fcm/commit/1ccad9b45a9462b5315f0e32612696a32dcbecd2))
91
-
92
- ### [1.0.1](https://github.com/capacitor-community/fcm/compare/v1.0.0...v1.0.1) (2020-06-27)
93
-
94
- ### Bug Fixes
95
-
96
- - **ios:** Fixing wrong Firebase dependency ([6e96be0](https://github.com/capacitor-community/fcm/commit/6e96be0388e67c28c389debd26a11ed3b145e4af))
97
-
98
- ## 1.0.0 (2020-06-27)
99
-
100
- ### Features
101
-
102
- - **README:** add androidy notes ([9042cba](https://github.com/capacitor-community/fcm/commit/9042cba2bf1182bb0542177ba8fd1303b492009b))
103
- - add android support ([f3caba1](https://github.com/capacitor-community/fcm/commit/f3caba115a593a9fbb918ee63c2427c3ce5d0870))
104
- - **FCM:** add subscribe to topic ([6f0f88d](https://github.com/capacitor-community/fcm/commit/6f0f88db173a726ae4b412bfe9b0333f296ed327))
105
- - **ios:** add getToken and clean project to be publish ([ddec39b](https://github.com/capacitor-community/fcm/commit/ddec39b666e3338a5dd73b39c33510c2eb84c4e7))
106
- - add README ([863cb25](https://github.com/capacitor-community/fcm/commit/863cb25361fb7ecd8dcd63c64f7181f9d7f5b72f))
107
- - add unsubscribe from topic ([a6a3dee](https://github.com/capacitor-community/fcm/commit/a6a3dee09b5b2faaca01e50fc2cedb1992df41d5))
108
-
109
- ### Bug Fixes
110
-
111
- - **android:** add app compat ([5709b1d](https://github.com/capacitor-community/fcm/commit/5709b1dadbd62d1f62b0be86bb1229e9f4e9bc5f))
112
- - **android:** add deps ([9927aee](https://github.com/capacitor-community/fcm/commit/9927aeee0637945520bea03b69f609a0806b5767))
113
- - **android:** cap implementation ([b394973](https://github.com/capacitor-community/fcm/commit/b3949730c7ff27afb3a5f4a94dce60360590acde))
114
- - **android:** package name ([f148a20](https://github.com/capacitor-community/fcm/commit/f148a203551e457a89eed8fedaf24c8fe925b88a))
115
- - **ios:** notifications were not being delivered on a freshed app install ([f3d10a5](https://github.com/capacitor-community/fcm/commit/f3d10a59a866c0c92cbfd91a3a400c6126de03cb))
116
- - **ios:** notifications were not being delivered on a freshed app install ([3205224](https://github.com/capacitor-community/fcm/commit/3205224885465a186a830c9679f4b3ce5abdb321))
117
- - **ios:** plugin not working on Case-Sensitive file system ([1deb869](https://github.com/capacitor-community/fcm/commit/1deb86951dc23a337a7910f5df1bba7e48005d72))
118
- - **podspec:** add firebase back ([933ddbe](https://github.com/capacitor-community/fcm/commit/933ddbed2b168e2552aae7138914e7ed54d59492))
119
- - **README:** add sample app link ([ef67512](https://github.com/capacitor-community/fcm/commit/ef67512f94ffb317464006b1eb71a619a9e45079))
Binary file
Binary file
Binary file
Binary file