@capacitor-community/fcm 2.0.1 → 3.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/CapacitorCommunityFcm.podspec +1 -1
  3. package/README.md +14 -9
  4. package/android/build.gradle +14 -13
  5. package/android/src/main/java/com/getcapacitor/community/fcm/FCMPlugin.java +12 -0
  6. package/dist/esm/definitions.d.ts +15 -0
  7. package/dist/esm/definitions.js.map +1 -1
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/web.d.ts +3 -0
  10. package/dist/esm/web.js +4 -1
  11. package/dist/esm/web.js.map +1 -1
  12. package/dist/plugin.cjs.js +49 -0
  13. package/dist/plugin.cjs.js.map +1 -0
  14. package/dist/plugin.js +52 -0
  15. package/dist/plugin.js.map +1 -0
  16. package/ios/Plugin/Plugin/Plugin.swift +15 -0
  17. package/ios/Plugin/Podfile +1 -1
  18. package/package.json +59 -33
  19. package/android/.DS_Store +0 -0
  20. package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
  21. package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
  22. package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
  23. package/android/.gradle/5.6.4/gc.properties +0 -0
  24. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  25. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  26. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  27. package/android/.gradle/vcs-1/gc.properties +0 -0
  28. package/android/.idea/codeStyles/Project.xml +0 -113
  29. package/android/.idea/gradle.xml +0 -19
  30. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_0_jar.xml +0 -13
  31. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_0_0_jar.xml +0 -11
  32. package/android/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml +0 -14
  33. package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml +0 -14
  34. package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml +0 -14
  35. package/android/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml +0 -14
  36. package/android/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml +0 -14
  37. package/android/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml +0 -14
  38. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml +0 -9
  39. package/android/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml +0 -13
  40. package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml +0 -13
  41. package/android/.idea/libraries/Gradle__junit_junit_4_12_jar.xml +0 -13
  42. package/android/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml +0 -13
  43. package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml +0 -13
  44. package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml +0 -13
  45. package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml +0 -13
  46. package/android/.idea/misc.xml +0 -9
  47. package/android/.idea/modules.xml +0 -9
  48. package/android/.idea/runConfigurations.xml +0 -12
  49. package/android/.idea/vcs.xml +0 -6
  50. package/android/.idea/workspace.xml +0 -89
  51. package/android/.npmignore +0 -1
  52. package/android/android-capacitor-community-fcm.iml +0 -264
  53. package/android/android.iml +0 -108
  54. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  55. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  56. package/android/gradle.properties +0 -21
  57. package/android/gradlew +0 -160
  58. package/android/gradlew.bat +0 -90
  59. package/android/local.properties +0 -8
  60. package/android/proguard-rules.pro +0 -21
  61. package/android/settings.gradle +0 -2
  62. package/android/src/.DS_Store +0 -0
  63. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +0 -27
  64. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +0 -17
  65. package/ios/.DS_Store +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
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
+ ### [2.0.2](https://github.com/capacitor-community/fcm/compare/v2.0.1...v2.0.2) (2021-10-04)
6
+
5
7
  ### [2.0.1](https://github.com/capacitor-community/fcm/compare/v2.0.0...v2.0.1) (2021-09-13)
6
8
 
7
9
  ## [2.0.0](https://github.com/capacitor-community/fcm/compare/v1.1.2...v2.0.0) (2021-06-14)
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.source = { git: package['repository']['url'], tag: s.version.to_s }
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '12.0'
14
+ s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.dependency 'Firebase/Messaging'
17
17
  s.swift_version = '5.1'
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-15-orange?style=flat-square" /></a>
15
+ <a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-20-orange?style=flat-square" /></a>
16
16
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
17
17
 
18
18
  </p>
@@ -66,8 +66,8 @@ npx cap sync
66
66
  ## Usage
67
67
 
68
68
  ```ts
69
- import { FCM } from '@capacitor-community/fcm';
70
- import { PushNotifications } from '@capacitor/push-notifications';
69
+ import { FCM } from "@capacitor-community/fcm";
70
+ import { PushNotifications } from "@capacitor/push-notifications";
71
71
 
72
72
  // external required step
73
73
  // register for push
@@ -75,12 +75,12 @@ await PushNotifications.requestPermissions();
75
75
  await PushNotifications.register();
76
76
 
77
77
  // now you can subscribe to a specific topic
78
- FCM.subscribeTo({ topic: 'test' })
78
+ FCM.subscribeTo({ topic: "test" })
79
79
  .then((r) => alert(`subscribed to topic`))
80
80
  .catch((err) => console.log(err));
81
81
 
82
82
  // Unsubscribe from a specific topic
83
- FCM.unsubscribeFrom({ topic: 'test' })
83
+ FCM.unsubscribeFrom({ topic: "test" })
84
84
  .then(() => alert(`unsubscribed from topic`))
85
85
  .catch((err) => console.log(err));
86
86
 
@@ -99,7 +99,7 @@ FCM.setAutoInit({ enabled: true }).then(() => alert(`Auto init enabled`));
99
99
 
100
100
  // Check the auto initialization status
101
101
  FCM.isAutoInitEnabled().then((r) => {
102
- console.log('Auto init is ' + (r.enabled ? 'enabled' : 'disabled'));
102
+ console.log("Auto init is " + (r.enabled ? "enabled" : "disabled"));
103
103
  });
104
104
  ```
105
105
 
@@ -166,8 +166,6 @@ If you need to implement opt-in behavior, you can disable the auto initializatio
166
166
  - add `google-services.json` to your `android/app` folder
167
167
  - `[extra step]` in android case we need to tell Capacitor to initialise the plugin:
168
168
 
169
- > on your `MainActivity.java` file add `import com.getcapacitor.community.fcm.FCMPlugin;` and then inside the init callback `add(FCMPlugin.class);`
170
-
171
169
  Now you should be set to go. Try to run your client using `ionic cap run android --livereload`.
172
170
 
173
171
  > Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.
@@ -193,7 +191,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
193
191
  <!-- markdownlint-disable -->
194
192
  <table>
195
193
  <tr>
196
- <td align="center"><a href="https://twitter.com/StewanSilva"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Stew</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>
194
+ <td align="center"><a href="https://twitter.com/stewones"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Stew</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>
197
195
  <td align="center"><a href="https://github.com/danielprrazevedo"><img src="https://avatars2.githubusercontent.com/u/20153661?v=4?s=75" width="75px;" alt=""/><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>
198
196
  <td align="center"><a href="http://priyankpatel.io/"><img src="https://avatars3.githubusercontent.com/u/5585797?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Priyank Patel</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=priyankpat" title="Code">💻</a></td>
199
197
  <td align="center"><a href="http://fuubar.wordpress.com/"><img src="https://avatars1.githubusercontent.com/u/1230033?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Nikolas</b></sub></a><br /><a href="#maintenance-nikoskip" title="Maintenance">🚧</a></td>
@@ -213,6 +211,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
213
211
  <td align="center"><a href="https://github.com/mesqueeb"><img src="https://avatars.githubusercontent.com/u/3253920?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Luca Ban</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=mesqueeb" title="Documentation">📖</a></td>
214
212
  <td align="center"><a href="https://www.alexgriffith.me/"><img src="https://avatars.githubusercontent.com/u/5904472?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Alex Griffith</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=halomademeapc" title="Code">💻</a> <a href="#maintenance-halomademeapc" title="Maintenance">🚧</a></td>
215
213
  </tr>
214
+ <tr>
215
+ <td align="center"><a href="https://github.com/bdirito"><img src="https://avatars.githubusercontent.com/u/8117238?v=4?s=75" width="75px;" alt=""/><br /><sub><b>bdirito</b></sub></a><br /><a href="#maintenance-bdirito" title="Maintenance">🚧</a></td>
216
+ <td align="center"><a href="https://github.com/mineminemine"><img src="https://avatars.githubusercontent.com/u/17585549?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Ryan</b></sub></a><br /><a href="#maintenance-mineminemine" title="Maintenance">🚧</a></td>
217
+ <td align="center"><a href="https://github.com/josuelmm"><img src="https://avatars.githubusercontent.com/u/12968781?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Josué Moreno</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=josuelmm" title="Code">💻</a></td>
218
+ <td align="center"><a href="https://marcjulian.de/?ref=github"><img src="https://avatars.githubusercontent.com/u/8985933?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Marc</b></sub></a><br /><a href="#maintenance-marcjulian" title="Maintenance">🚧</a></td>
219
+ <td align="center"><a href="https://floriangyger.ch/"><img src="https://avatars.githubusercontent.com/u/1215256?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Florian Gyger</b></sub></a><br /><a href="https://github.com/capacitor-community/fcm/commits?author=flogy" title="Code">💻</a></td>
220
+ </tr>
216
221
  </table>
217
222
 
218
223
  <!-- markdownlint-restore -->
@@ -1,26 +1,28 @@
1
1
  ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
3
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
4
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
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 : '21.0.1'
5
7
  }
6
8
 
7
9
  buildscript {
8
10
  repositories {
9
11
  google()
10
- jcenter()
12
+ mavenCentral()
11
13
  }
12
14
  dependencies {
13
- classpath 'com.android.tools.build:gradle:3.6.1'
15
+ classpath 'com.android.tools.build:gradle:7.2.1'
14
16
  }
15
17
  }
16
18
 
17
19
  apply plugin: 'com.android.library'
18
20
 
19
21
  android {
20
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
21
23
  defaultConfig {
22
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
23
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
24
26
  versionCode 1
25
27
  versionName "1.0"
26
28
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -34,16 +36,15 @@ android {
34
36
  lintOptions {
35
37
  abortOnError false
36
38
  }
37
-
39
+
38
40
  compileOptions {
39
- sourceCompatibility JavaVersion.VERSION_1_8
40
- targetCompatibility JavaVersion.VERSION_1_8
41
+ sourceCompatibility JavaVersion.VERSION_11
42
+ targetCompatibility JavaVersion.VERSION_11
41
43
  }
42
44
  }
43
45
 
44
46
  repositories {
45
47
  google()
46
- jcenter()
47
48
  mavenCentral()
48
49
  }
49
50
 
@@ -55,6 +56,6 @@ dependencies {
55
56
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
56
57
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
57
58
  androidTestImplementation 'com.android.support:support-annotations:28.0.0'
58
- implementation 'com.google.firebase:firebase-messaging:22.0.0'
59
+ implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
59
60
  implementation 'com.android.support:appcompat-v7:28.0.0'
60
61
  }
@@ -63,6 +63,18 @@ public class FCMPlugin extends Plugin {
63
63
 
64
64
  @PluginMethod()
65
65
  public void getToken(final PluginCall call) {
66
+ FirebaseMessaging.getInstance().getToken().addOnCompleteListener(getActivity(), tokenResult -> {
67
+ JSObject data = new JSObject();
68
+ data.put("token", tokenResult.getResult());
69
+ call.resolve(data);
70
+ });
71
+
72
+ FirebaseMessaging.getInstance().getToken().addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e));
73
+ }
74
+
75
+ @PluginMethod()
76
+ public void refreshToken(final PluginCall call) {
77
+ FirebaseMessaging.getInstance().deleteToken();
66
78
  FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult -> {
67
79
  JSObject data = new JSObject();
68
80
  data.put("token", instanceIdResult.getToken());
@@ -32,6 +32,21 @@ export interface FCMPlugin {
32
32
  getToken(): Promise<{
33
33
  token: string;
34
34
  }>;
35
+ /**
36
+ * Refresh fcm token to eventually use from a serve
37
+ *
38
+ * Recommended to use this instead of
39
+ * @usage
40
+ * ```typescript
41
+ * PushNotifications.addListener("registration", (token) => {
42
+ * console.log(token.data);
43
+ * });
44
+ * ```
45
+ * because the native capacitor method, for apple, returns the APN's token
46
+ */
47
+ refreshToken(): Promise<{
48
+ token: string;
49
+ }>;
35
50
  /**
36
51
  * Remove local fcm instance completely
37
52
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface FCMPlugin {\n /**\n * Subscribe to fcm topic\n * @param options\n */\n subscribeTo(options: { topic: string }): Promise<{ message: string }>;\n\n /**\n * Unsubscribe from fcm topic\n * @param options\n */\n unsubscribeFrom(options: { topic: string }): Promise<{ message: string }>;\n\n /**\n * Get fcm token to eventually use from a serve\n *\n * Recommended to use this instead of\n * @usage\n * ```typescript\n * PushNotifications.addListener(\"registration\", (token) => {\n * console.log(token.data);\n * });\n * ```\n * because the native capacitor method, for apple, returns the APN's token\n */\n getToken(): Promise<{ token: string }>;\n\n \n /**\n * Refresh fcm token to eventually use from a serve\n *\n * Recommended to use this instead of\n * @usage\n * ```typescript\n * PushNotifications.addListener(\"registration\", (token) => {\n * console.log(token.data);\n * });\n * ```\n * because the native capacitor method, for apple, returns the APN's token\n */\n refreshToken(): Promise<{ token: string }>;\n\n /**\n * Remove local fcm instance completely\n */\n deleteInstance(): Promise<boolean>;\n\n /**\n * Enabled/disabled auto initialization.\n * @param options\n */\n setAutoInit(options: { enabled: boolean }): Promise<void>;\n\n /**\n * Retrieve the auto initialization status.\n */\n isAutoInitEnabled(): Promise<{ enabled: boolean }>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,GAAG,GAAG,cAAc,CACtB,KAAK,EACL;IACI,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;CACzD,CACJ,CAAC;AAEF,kCAAkC;AAClC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,GAAG,GAAG,cAAc,CACtB,KAAK,EACL;IACI,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;CACzD,CACJ,CAAC;AAEF,kCAAkC;AAClC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nimport { FCMPlugin } from \"./definitions\";\n\nconst FCM = registerPlugin<FCMPlugin>(\n \"FCM\",\n {\n web: () => import(\"./web\").then((m) => new m.FCMWeb()),\n }\n);\n\n// export * from './web'; // @todo\nexport * from \"./definitions\";\nexport { FCM };\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -22,6 +22,9 @@ export declare class FCMWeb extends WebPlugin implements FCMPlugin {
22
22
  isAutoInitEnabled(): Promise<{
23
23
  enabled: boolean;
24
24
  }>;
25
+ refreshToken(): Promise<{
26
+ token: string;
27
+ }>;
25
28
  }
26
29
  declare const FCM: FCMWeb;
27
30
  export { FCM };
package/dist/esm/web.js CHANGED
@@ -3,7 +3,7 @@ export class FCMWeb extends WebPlugin {
3
3
  constructor() {
4
4
  super({
5
5
  name: 'FCM',
6
- platforms: ['web']
6
+ platforms: ['web'],
7
7
  });
8
8
  }
9
9
  subscribeTo(_options) {
@@ -24,6 +24,9 @@ export class FCMWeb extends WebPlugin {
24
24
  isAutoInitEnabled() {
25
25
  throw this.unimplemented('Not implemented on web.');
26
26
  }
27
+ refreshToken() {
28
+ throw this.unimplemented('Not implemented on web.');
29
+ }
27
30
  }
28
31
  const FCM = new FCMWeb();
29
32
  export { FCM };
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnC;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IACD,WAAW,CAAC,QAA4B;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,eAAe,CAAC,QAA4B;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,QAAQ;QACN,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,cAAc;QACZ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,WAAW,CAAC,QAA+B;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,iBAAiB;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;AAEzB,OAAO,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnC;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,WAAW,CAAC,QAA2B;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,eAAe,CAAC,QAA2B;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;QACZ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,WAAW,CAAC,QAA8B;QACxC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,iBAAiB;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,YAAY;QACV,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;AAEzB,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport { FCMPlugin } from './definitions';\n\nexport class FCMWeb extends WebPlugin implements FCMPlugin {\n constructor() {\n super({\n name: 'FCM',\n platforms: ['web'],\n });\n }\n\n subscribeTo(_options: { topic: string }): Promise<{ message: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n unsubscribeFrom(_options: { topic: string }): Promise<{ message: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n getToken(): Promise<{ token: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n deleteInstance(): Promise<boolean> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n setAutoInit(_options: { enabled: boolean }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n isAutoInitEnabled(): Promise<{ enabled: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n refreshToken(): Promise<{ token: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n\nconst FCM = new FCMWeb();\n\nexport { FCM };\n"]}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const FCM$1 = core.registerPlugin("FCM", {
8
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.FCMWeb()),
9
+ });
10
+
11
+ class FCMWeb extends core.WebPlugin {
12
+ constructor() {
13
+ super({
14
+ name: 'FCM',
15
+ platforms: ['web'],
16
+ });
17
+ }
18
+ subscribeTo(_options) {
19
+ throw this.unimplemented('Not implemented on web.');
20
+ }
21
+ unsubscribeFrom(_options) {
22
+ throw this.unimplemented('Not implemented on web.');
23
+ }
24
+ getToken() {
25
+ throw this.unimplemented('Not implemented on web.');
26
+ }
27
+ deleteInstance() {
28
+ throw this.unimplemented('Not implemented on web.');
29
+ }
30
+ setAutoInit(_options) {
31
+ throw this.unimplemented('Not implemented on web.');
32
+ }
33
+ isAutoInitEnabled() {
34
+ throw this.unimplemented('Not implemented on web.');
35
+ }
36
+ refreshToken() {
37
+ throw this.unimplemented('Not implemented on web.');
38
+ }
39
+ }
40
+ const FCM = new FCMWeb();
41
+
42
+ var web = /*#__PURE__*/Object.freeze({
43
+ __proto__: null,
44
+ FCMWeb: FCMWeb,
45
+ FCM: FCM
46
+ });
47
+
48
+ exports.FCM = FCM$1;
49
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst FCM = registerPlugin(\"FCM\", {\n web: () => import(\"./web\").then((m) => new m.FCMWeb()),\n});\n// export * from './web'; // @todo\nexport * from \"./definitions\";\nexport { FCM };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FCMWeb extends WebPlugin {\n constructor() {\n super({\n name: 'FCM',\n platforms: ['web'],\n });\n }\n subscribeTo(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n unsubscribeFrom(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n getToken() {\n throw this.unimplemented('Not implemented on web.');\n }\n deleteInstance() {\n throw this.unimplemented('Not implemented on web.');\n }\n setAutoInit(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n isAutoInitEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n refreshToken() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst FCM = new FCMWeb();\nexport { FCM };\n//# sourceMappingURL=web.js.map"],"names":["FCM","registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAACA,KAAG,GAAGC,mBAAc,CAAC,KAAK,EAAE;AAClC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAC1D,CAAC;;ACFM,MAAM,MAAM,SAASC,cAAS,CAAC;AACtC,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,KAAK;AACvB,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,WAAW,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,eAAe,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,QAAQ,GAAG;AACf,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,cAAc,GAAG;AACrB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,WAAW,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,iBAAiB,GAAG;AACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,YAAY,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,CAAC;AACD,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE;;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,52 @@
1
+ var capacitorPlugin = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const FCM$1 = core.registerPlugin("FCM", {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.FCMWeb()),
6
+ });
7
+
8
+ class FCMWeb extends core.WebPlugin {
9
+ constructor() {
10
+ super({
11
+ name: 'FCM',
12
+ platforms: ['web'],
13
+ });
14
+ }
15
+ subscribeTo(_options) {
16
+ throw this.unimplemented('Not implemented on web.');
17
+ }
18
+ unsubscribeFrom(_options) {
19
+ throw this.unimplemented('Not implemented on web.');
20
+ }
21
+ getToken() {
22
+ throw this.unimplemented('Not implemented on web.');
23
+ }
24
+ deleteInstance() {
25
+ throw this.unimplemented('Not implemented on web.');
26
+ }
27
+ setAutoInit(_options) {
28
+ throw this.unimplemented('Not implemented on web.');
29
+ }
30
+ isAutoInitEnabled() {
31
+ throw this.unimplemented('Not implemented on web.');
32
+ }
33
+ refreshToken() {
34
+ throw this.unimplemented('Not implemented on web.');
35
+ }
36
+ }
37
+ const FCM = new FCMWeb();
38
+
39
+ var web = /*#__PURE__*/Object.freeze({
40
+ __proto__: null,
41
+ FCMWeb: FCMWeb,
42
+ FCM: FCM
43
+ });
44
+
45
+ exports.FCM = FCM$1;
46
+
47
+ Object.defineProperty(exports, '__esModule', { value: true });
48
+
49
+ return exports;
50
+
51
+ })({}, capacitorExports);
52
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst FCM = registerPlugin(\"FCM\", {\n web: () => import(\"./web\").then((m) => new m.FCMWeb()),\n});\n// export * from './web'; // @todo\nexport * from \"./definitions\";\nexport { FCM };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FCMWeb extends WebPlugin {\n constructor() {\n super({\n name: 'FCM',\n platforms: ['web'],\n });\n }\n subscribeTo(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n unsubscribeFrom(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n getToken() {\n throw this.unimplemented('Not implemented on web.');\n }\n deleteInstance() {\n throw this.unimplemented('Not implemented on web.');\n }\n setAutoInit(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n isAutoInitEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n refreshToken() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst FCM = new FCMWeb();\nexport { FCM };\n//# sourceMappingURL=web.js.map"],"names":["FCM","registerPlugin","WebPlugin"],"mappings":";;;AACK,UAACA,KAAG,GAAGC,mBAAc,CAAC,KAAK,EAAE;IAClC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,CAAC;;ICFM,MAAM,MAAM,SAASC,cAAS,CAAC;IACtC,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC;IACd,YAAY,IAAI,EAAE,KAAK;IACvB,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,WAAW,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,eAAe,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,QAAQ,GAAG;IACf,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,cAAc,GAAG;IACrB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,WAAW,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,iBAAiB,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,YAAY,GAAG;IACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE;;;;;;;;;;;;;;;;;;"}
@@ -80,6 +80,21 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
80
80
  ])
81
81
  }
82
82
  }
83
+
84
+ @objc func refreshToken(_ call: CAPPluginCall) {
85
+ Messaging.messaging().token { token, error in
86
+ if let error = error {
87
+ print("Error fetching FCM registration token: \(error)")
88
+ call.reject("Failed to get instance FirebaseID", error.localizedDescription)
89
+ } else if let token = token {
90
+ print("FCM registration token: \(token)");
91
+ self.fcmToken = token;
92
+ call.resolve([
93
+ "token": token
94
+ ]);
95
+ }
96
+ }
97
+ }
83
98
 
84
99
  @objc func deleteInstance(_ call: CAPPluginCall) {
85
100
  Installations.installations().delete { error in
@@ -1,5 +1,5 @@
1
1
  # Uncomment the next line to define a global platform for your project
2
- platform :ios, '12.0'
2
+ platform :ios, '13.0'
3
3
 
4
4
  def capacitor_pods
5
5
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
package/package.json CHANGED
@@ -1,39 +1,28 @@
1
1
  {
2
2
  "name": "@capacitor-community/fcm",
3
- "version": "2.0.1",
3
+ "version": "3.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",
7
7
  "types": "dist/esm/index.d.ts",
8
- "scripts": {
9
- "build": "npm run clean && tsc",
10
- "clean": "rm -rf ./dist",
11
- "watch": "tsc --watch",
12
- "prepublishOnly": "npm run build",
13
- "release:patch": "standard-version release --release-as patch",
14
- "release:minor": "standard-version release --release-as minor",
15
- "release:major": "standard-version release --release-as major",
16
- "contributors:add": "all-contributors add",
17
- "contributors:gen": "all-contributors generate"
18
- },
19
- "author": "Stewan Silva",
20
- "license": "MIT",
21
- "dependencies": {
22
- "@capacitor/core": "^3.0.1"
23
- },
24
- "devDependencies": {
25
- "@capacitor/android": "^3.0.1",
26
- "@capacitor/cli": "^3.0.1",
27
- "@capacitor/ios": "^3.0.1",
28
- "all-contributors-cli": "^6.16.0",
29
- "typescript": "~4.0.0"
30
- },
8
+ "unpkg": "dist/plugin.js",
31
9
  "files": [
10
+ "android/src/main",
11
+ "android/build.gradle",
32
12
  "dist/",
33
- "ios/",
34
- "android/",
13
+ "ios/Plugin",
35
14
  "CapacitorCommunityFcm.podspec"
36
15
  ],
16
+ "author": "Stewan Silva",
17
+ "license": "MIT",
18
+ "homepage": "https://github.com/capacitor-community/fcm#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/capacitor-community/fcm.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/capacitor-community/fcm/issues"
25
+ },
37
26
  "keywords": [
38
27
  "capacitor",
39
28
  "plugin",
@@ -41,6 +30,50 @@
41
30
  "fcm",
42
31
  "firebase cloud messaging"
43
32
  ],
33
+ "scripts": {
34
+ "build": "npm run clean && tsc && rollup -c rollup.config.js",
35
+ "clean": "rimraf ./dist",
36
+ "watch": "tsc --watch",
37
+ "prepublishOnly": "npm run build",
38
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
39
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
40
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
41
+ "verify:web": "npm run build",
42
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
43
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
44
+ "eslint": "eslint . --ext ts",
45
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
46
+ "swiftlint": "node-swiftlint",
47
+ "release:patch": "standard-version release --release-as patch",
48
+ "release:minor": "standard-version release --release-as minor",
49
+ "release:major": "standard-version release --release-as major",
50
+ "contributors:add": "all-contributors add",
51
+ "contributors:gen": "all-contributors generate"
52
+ },
53
+ "devDependencies": {
54
+ "@capacitor/android": "^4.0.0",
55
+ "@capacitor/core": "^4.0.0",
56
+ "@capacitor/docgen": "^0.0.18",
57
+ "@capacitor/ios": "^4.0.0",
58
+ "@ionic/eslint-config": "^0.3.0",
59
+ "@ionic/prettier-config": "^1.0.1",
60
+ "@ionic/swiftlint-config": "^1.1.2",
61
+ "eslint": "^7.11.0",
62
+ "prettier": "~2.3.0",
63
+ "prettier-plugin-java": "~1.0.2",
64
+ "rimraf": "^3.0.2",
65
+ "rollup": "^2.32.0",
66
+ "swiftlint": "^1.0.1",
67
+ "typescript": "~4.1.5"
68
+ },
69
+ "peerDependencies": {
70
+ "@capacitor/core": "^4.0.0"
71
+ },
72
+ "prettier": "@ionic/prettier-config",
73
+ "swiftlint": "@ionic/swiftlint-config",
74
+ "eslintConfig": {
75
+ "extends": "@ionic/eslint-config/recommended"
76
+ },
44
77
  "capacitor": {
45
78
  "ios": {
46
79
  "src": "ios"
@@ -48,12 +81,5 @@
48
81
  "android": {
49
82
  "src": "android"
50
83
  }
51
- },
52
- "repository": {
53
- "type": "git",
54
- "url": "https://github.com/capacitor-community/fcm"
55
- },
56
- "bugs": {
57
- "url": "https://github.com/capacitor-community/fcm/issues"
58
84
  }
59
85
  }
package/android/.DS_Store DELETED
Binary file
File without changes
@@ -1,2 +0,0 @@
1
- #Mon Jun 29 11:05:41 BRT 2020
2
- gradle.version=5.6.4
File without changes