@capacitor-community/fcm 7.0.0 → 7.1.1
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/CapacitorCommunityFcm.podspec +1 -1
- package/android/src/main/java/com/getcapacitor/community/fcm/FCMPlugin.java +58 -56
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -5
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -5
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/{Plugin/Plugin.swift → Plugin.swift} +36 -37
- package/package.json +1 -1
- package/android/src/main/res/layout/bridge_layout_main.xml +0 -15
- package/android/src/main/res/values/colors.xml +0 -3
- package/android/src/main/res/values/strings.xml +0 -3
- package/android/src/main/res/values/styles.xml +0 -3
- package/ios/Plugin/Plugin.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/Plugin/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Plugin/Plugin.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Plugin/Plugin.xcworkspace/xcuserdata/max.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -23
- package/ios/Plugin/Plugin.xcworkspace/xcuserdata/stewan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Plugin/PluginTests/Info.plist +0 -22
- package/ios/Plugin/PluginTests/PluginTests.swift +0 -35
- package/ios/Plugin/Podfile +0 -20
- /package/ios/Plugin/{Plugin/Info.plist → Info.plist} +0 -0
- /package/ios/Plugin/{Plugin/Plugin.h → Plugin.h} +0 -0
- /package/ios/Plugin/{Plugin/Plugin.m → Plugin.m} +0 -0
|
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency '
|
|
16
|
+
s.dependency 'FirebaseMessaging'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
s.static_framework = true
|
|
19
19
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.getcapacitor.community.fcm;
|
|
2
2
|
|
|
3
3
|
import android.util.Log;
|
|
4
|
-
|
|
5
4
|
import com.getcapacitor.JSObject;
|
|
6
5
|
import com.getcapacitor.Plugin;
|
|
7
6
|
import com.getcapacitor.PluginCall;
|
|
@@ -16,91 +15,94 @@ import com.google.firebase.messaging.FirebaseMessaging;
|
|
|
16
15
|
*
|
|
17
16
|
* Created by Stewan Silva on 1/23/19.
|
|
18
17
|
*/
|
|
19
|
-
@CapacitorPlugin(
|
|
20
|
-
name = "FCM"
|
|
21
|
-
)
|
|
18
|
+
@CapacitorPlugin(name = "FCM")
|
|
22
19
|
public class FCMPlugin extends Plugin {
|
|
23
20
|
|
|
24
21
|
public static final String TAG = "FirebaseMessaging";
|
|
25
22
|
|
|
26
|
-
@PluginMethod
|
|
23
|
+
@PluginMethod
|
|
27
24
|
public void subscribeTo(final PluginCall call) {
|
|
28
25
|
final String topicName = call.getString("topic");
|
|
29
26
|
|
|
30
|
-
FirebaseMessaging
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.addOnFailureListener(e -> call.reject("Cant subscribe to topic" + topicName, e));
|
|
39
|
-
|
|
27
|
+
FirebaseMessaging.getInstance()
|
|
28
|
+
.subscribeToTopic(topicName)
|
|
29
|
+
.addOnSuccessListener(aVoid -> {
|
|
30
|
+
JSObject ret = new JSObject();
|
|
31
|
+
ret.put("message", "Subscribed to topic " + topicName);
|
|
32
|
+
call.resolve(ret);
|
|
33
|
+
})
|
|
34
|
+
.addOnFailureListener(e -> call.reject("Cant subscribe to topic" + topicName, e));
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
@PluginMethod
|
|
37
|
+
@PluginMethod
|
|
43
38
|
public void unsubscribeFrom(final PluginCall call) {
|
|
44
39
|
final String topicName = call.getString("topic");
|
|
45
40
|
|
|
46
|
-
FirebaseMessaging
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.addOnFailureListener(e -> call.reject("Cant unsubscribe from topic" + topicName, e));
|
|
55
|
-
|
|
41
|
+
FirebaseMessaging.getInstance()
|
|
42
|
+
.unsubscribeFromTopic(topicName)
|
|
43
|
+
.addOnSuccessListener(aVoid -> {
|
|
44
|
+
JSObject ret = new JSObject();
|
|
45
|
+
ret.put("message", "Unsubscribed from topic " + topicName);
|
|
46
|
+
call.resolve(ret);
|
|
47
|
+
})
|
|
48
|
+
.addOnFailureListener(e -> call.reject("Cant unsubscribe from topic" + topicName, e));
|
|
56
49
|
}
|
|
57
50
|
|
|
58
|
-
@PluginMethod
|
|
51
|
+
@PluginMethod
|
|
59
52
|
public void deleteInstance(final PluginCall call) {
|
|
60
|
-
FirebaseInstallations.getInstance()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
FirebaseInstallations.getInstance()
|
|
54
|
+
.delete()
|
|
55
|
+
.addOnSuccessListener(aVoid -> call.resolve())
|
|
56
|
+
.addOnFailureListener(e -> {
|
|
57
|
+
e.printStackTrace();
|
|
58
|
+
call.reject("Cant delete Firebase Instance ID", e);
|
|
59
|
+
});
|
|
66
60
|
}
|
|
67
61
|
|
|
68
|
-
@PluginMethod
|
|
62
|
+
@PluginMethod
|
|
69
63
|
public void getToken(final PluginCall call) {
|
|
70
|
-
FirebaseMessaging.getInstance()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
64
|
+
FirebaseMessaging.getInstance()
|
|
65
|
+
.getToken()
|
|
66
|
+
.addOnCompleteListener(getActivity(), tokenResult -> {
|
|
67
|
+
if (!tokenResult.isSuccessful()) {
|
|
68
|
+
Exception exception = tokenResult.getException();
|
|
69
|
+
Log.w(TAG, "Fetching FCM registration token failed", exception);
|
|
70
|
+
call.errorCallback(exception.getLocalizedMessage());
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
JSObject data = new JSObject();
|
|
74
|
+
data.put("token", tokenResult.getResult());
|
|
75
|
+
call.resolve(data);
|
|
76
|
+
});
|
|
81
77
|
|
|
82
78
|
FirebaseMessaging.getInstance().getToken().addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e));
|
|
83
79
|
}
|
|
84
|
-
|
|
85
|
-
@PluginMethod
|
|
80
|
+
|
|
81
|
+
@PluginMethod
|
|
86
82
|
public void refreshToken(final PluginCall call) {
|
|
87
|
-
FirebaseMessaging.getInstance()
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
FirebaseMessaging.getInstance()
|
|
84
|
+
.deleteToken()
|
|
85
|
+
.addOnCompleteListener(result -> {
|
|
86
|
+
FirebaseMessaging.getInstance()
|
|
87
|
+
.getToken()
|
|
88
|
+
.addOnCompleteListener(getActivity(), tokenResult -> {
|
|
89
|
+
JSObject data = new JSObject();
|
|
90
|
+
data.put("token", tokenResult.getResult());
|
|
91
|
+
call.resolve(data);
|
|
92
|
+
})
|
|
93
|
+
.addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e));
|
|
94
|
+
})
|
|
95
|
+
.addOnFailureListener(e -> call.reject("Failed to delete FCM registration token", e));
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
@PluginMethod
|
|
98
|
+
@PluginMethod
|
|
97
99
|
public void setAutoInit(final PluginCall call) {
|
|
98
100
|
final boolean enabled = call.getBoolean("enabled", false);
|
|
99
101
|
FirebaseMessaging.getInstance().setAutoInitEnabled(enabled);
|
|
100
102
|
call.resolve();
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
@PluginMethod
|
|
105
|
+
@PluginMethod
|
|
104
106
|
public void isAutoInitEnabled(final PluginCall call) {
|
|
105
107
|
final boolean enabled = FirebaseMessaging.getInstance().isAutoInitEnabled();
|
|
106
108
|
JSObject data = new JSObject();
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 * 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"]}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { registerPlugin } from
|
|
2
|
-
const FCM = registerPlugin(
|
|
3
|
-
web: () => import(
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const FCM = registerPlugin('FCM', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.FCMWeb()),
|
|
4
4
|
});
|
|
5
5
|
// export * from './web'; // @todo
|
|
6
|
-
export * from
|
|
6
|
+
export * from './definitions';
|
|
7
7
|
export { FCM };
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,GAAG,GAAG,cAAc,CAAY,KAAK,EAAE;IAC3C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;CACvD,CAAC,CAAC;AAEH,kCAAkC;AAClC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { FCMPlugin } from './definitions';\n\nconst FCM = registerPlugin<FCMPlugin>('FCM', {\n web: () => import('./web').then((m) => new m.FCMWeb()),\n});\n\n// export * from './web'; // @todo\nexport * from './definitions';\nexport { FCM };\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnC;QACE,KAAK,EAAE,CAAC;IACV,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';\n\nimport type { FCMPlugin } from './definitions';\n\nexport class FCMWeb extends WebPlugin implements FCMPlugin {\n constructor() {\n super();\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"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@capacitor/core');
|
|
6
4
|
|
|
7
|
-
const FCM$1 = core.registerPlugin(
|
|
5
|
+
const FCM$1 = core.registerPlugin('FCM', {
|
|
8
6
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.FCMWeb()),
|
|
9
7
|
});
|
|
10
8
|
|
|
@@ -38,8 +36,8 @@ const FCM = new FCMWeb();
|
|
|
38
36
|
|
|
39
37
|
var web = /*#__PURE__*/Object.freeze({
|
|
40
38
|
__proto__: null,
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
FCM: FCM,
|
|
40
|
+
FCMWeb: FCMWeb
|
|
43
41
|
});
|
|
44
42
|
|
|
45
43
|
exports.FCM = FCM$1;
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from
|
|
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 }\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,EAAE;AACf;AACA,IAAI,WAAW,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,eAAe,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,QAAQ,GAAG;AACf,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,cAAc,GAAG;AACrB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,WAAW,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,iBAAiB,GAAG;AACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA,IAAI,YAAY,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA;AACA,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE;;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var capacitorPlugin = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const FCM$1 = core.registerPlugin(
|
|
4
|
+
const FCM$1 = core.registerPlugin('FCM', {
|
|
5
5
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.FCMWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
@@ -35,14 +35,12 @@ var capacitorPlugin = (function (exports, core) {
|
|
|
35
35
|
|
|
36
36
|
var web = /*#__PURE__*/Object.freeze({
|
|
37
37
|
__proto__: null,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
FCM: FCM,
|
|
39
|
+
FCMWeb: FCMWeb
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
exports.FCM = FCM$1;
|
|
43
43
|
|
|
44
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
45
|
-
|
|
46
44
|
return exports;
|
|
47
45
|
|
|
48
46
|
})({}, capacitorExports);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from
|
|
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 }\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,EAAE;IACf;IACA,IAAI,WAAW,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,eAAe,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,QAAQ,GAAG;IACf,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,cAAc,GAAG;IACrB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,WAAW,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,iBAAiB,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA,IAAI,YAAY,GAAG;IACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA;IACA,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE;;;;;;;;;;;;;;;;"}
|
|
@@ -14,51 +14,51 @@ import FirebaseInstallations
|
|
|
14
14
|
*/
|
|
15
15
|
@objc(FCMPlugin)
|
|
16
16
|
public class FCMPlugin: CAPPlugin, MessagingDelegate {
|
|
17
|
-
var fcmToken: String
|
|
18
|
-
|
|
19
|
-
public
|
|
20
|
-
if
|
|
21
|
-
FirebaseApp.configure()
|
|
17
|
+
var fcmToken: String?
|
|
18
|
+
|
|
19
|
+
override public func load() {
|
|
20
|
+
if FirebaseApp.app() == nil {
|
|
21
|
+
FirebaseApp.configure()
|
|
22
22
|
}
|
|
23
23
|
Messaging.messaging().delegate = self
|
|
24
24
|
NotificationCenter.default.addObserver(self, selector: #selector(self.didRegisterWithToken(notification:)), name: .capacitorDidRegisterForRemoteNotifications, object: nil)
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
@objc func didRegisterWithToken(notification: NSNotification) {
|
|
28
28
|
guard let deviceToken = notification.object as? Data else {
|
|
29
29
|
return
|
|
30
30
|
}
|
|
31
31
|
Messaging.messaging().apnsToken = deviceToken
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
@objc func subscribeTo(_ call: CAPPluginCall) {
|
|
35
35
|
let topicName = call.getString("topic") ?? ""
|
|
36
36
|
Messaging.messaging().subscribe(toTopic: topicName) { error in
|
|
37
37
|
// print("Subscribed to weather topic")
|
|
38
|
-
if (
|
|
38
|
+
if (error) != nil {
|
|
39
39
|
print("ERROR while trying to subscribe topic \(topicName)")
|
|
40
40
|
call.reject("Can't subscribe to topic \(topicName)")
|
|
41
|
-
}else{
|
|
41
|
+
} else {
|
|
42
42
|
call.resolve([
|
|
43
43
|
"message": "subscribed to topic \(topicName)"
|
|
44
44
|
])
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
@objc func unsubscribeFrom(_ call: CAPPluginCall) {
|
|
50
50
|
let topicName = call.getString("topic") ?? ""
|
|
51
51
|
Messaging.messaging().unsubscribe(fromTopic: topicName) { error in
|
|
52
|
-
if (
|
|
52
|
+
if (error) != nil {
|
|
53
53
|
call.reject("Can't unsubscribe from topic \(topicName)")
|
|
54
|
-
}else{
|
|
54
|
+
} else {
|
|
55
55
|
call.resolve([
|
|
56
56
|
"message": "unsubscribed from topic \(topicName)"
|
|
57
57
|
])
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
@objc func getToken(_ call: CAPPluginCall) {
|
|
63
63
|
if (fcmToken ?? "").isEmpty {
|
|
64
64
|
Messaging.messaging().token { token, error in
|
|
@@ -66,15 +66,14 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
|
|
|
66
66
|
print("Error fetching FCM registration token: \(error)")
|
|
67
67
|
call.reject("Failed to get instance FirebaseID", error.localizedDescription)
|
|
68
68
|
} else if let token = token {
|
|
69
|
-
print("FCM registration token: \(token)")
|
|
70
|
-
self.fcmToken = token
|
|
69
|
+
print("FCM registration token: \(token)")
|
|
70
|
+
self.fcmToken = token
|
|
71
71
|
call.resolve([
|
|
72
72
|
"token": token
|
|
73
|
-
])
|
|
73
|
+
])
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
}
|
|
77
|
-
else{
|
|
76
|
+
} else {
|
|
78
77
|
call.resolve([
|
|
79
78
|
"token": fcmToken
|
|
80
79
|
])
|
|
@@ -84,12 +83,12 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
|
|
|
84
83
|
@objc func refreshToken(_ call: CAPPluginCall) {
|
|
85
84
|
// Delete FCM Token on Firebase
|
|
86
85
|
FirebaseMessaging.Messaging.messaging().deleteData { error in
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
guard let error = error else {
|
|
87
|
+
print("Delete FCMToken successful!")
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
call.reject("Delete FCMToken failed", error.localizedDescription)
|
|
91
|
+
print("Delete FCMToken failed: \(String(describing: error.localizedDescription))!")
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
Messaging.messaging().token { token, error in
|
|
@@ -97,15 +96,15 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
|
|
|
97
96
|
print("Error fetching FCM registration token: \(error)")
|
|
98
97
|
call.reject("Failed to get instance FirebaseID", error.localizedDescription)
|
|
99
98
|
} else if let token = token {
|
|
100
|
-
print("FCM registration token: \(token)")
|
|
101
|
-
self.fcmToken = token
|
|
99
|
+
print("FCM registration token: \(token)")
|
|
100
|
+
self.fcmToken = token
|
|
102
101
|
call.resolve([
|
|
103
102
|
"token": token
|
|
104
|
-
])
|
|
103
|
+
])
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
|
|
107
|
+
|
|
109
108
|
@objc func deleteInstance(_ call: CAPPluginCall) {
|
|
110
109
|
Installations.installations().delete { error in
|
|
111
110
|
if let error = error {
|
|
@@ -113,24 +112,24 @@ public class FCMPlugin: CAPPlugin, MessagingDelegate {
|
|
|
113
112
|
call.reject("Cant delete Firebase Instance ID", error.localizedDescription)
|
|
114
113
|
}
|
|
115
114
|
// reset fcmToken
|
|
116
|
-
self.fcmToken = ""
|
|
117
|
-
call.resolve()
|
|
115
|
+
self.fcmToken = ""
|
|
116
|
+
call.resolve()
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
|
|
121
120
|
@objc func setAutoInit(_ call: CAPPluginCall) {
|
|
122
121
|
let enabled: Bool = call.getBool("enabled") ?? false
|
|
123
|
-
Messaging.messaging().isAutoInitEnabled = enabled
|
|
124
|
-
call.resolve()
|
|
122
|
+
Messaging.messaging().isAutoInitEnabled = enabled
|
|
123
|
+
call.resolve()
|
|
125
124
|
}
|
|
126
|
-
|
|
125
|
+
|
|
127
126
|
@objc func isAutoInitEnabled(_ call: CAPPluginCall) {
|
|
128
127
|
call.resolve([
|
|
129
128
|
"enabled": Messaging.messaging().isAutoInitEnabled
|
|
130
|
-
])
|
|
129
|
+
])
|
|
131
130
|
}
|
|
132
|
-
|
|
131
|
+
|
|
133
132
|
@objc public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
|
134
|
-
self.fcmToken = fcmToken
|
|
133
|
+
self.fcmToken = fcmToken
|
|
135
134
|
}
|
|
136
135
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
4
|
-
xmlns:tools="http://schemas.android.com/tools"
|
|
5
|
-
android:layout_width="match_parent"
|
|
6
|
-
android:layout_height="match_parent"
|
|
7
|
-
tools:context="com.getcapacitor.BridgeActivity"
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
<WebView
|
|
11
|
-
android:id="@+id/webview"
|
|
12
|
-
android:layout_width="fill_parent"
|
|
13
|
-
android:layout_height="fill_parent" />
|
|
14
|
-
|
|
15
|
-
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
package/ios/Plugin/Plugin.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate
DELETED
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<Bucket
|
|
3
|
-
type = "0"
|
|
4
|
-
version = "2.0">
|
|
5
|
-
<Breakpoints>
|
|
6
|
-
<BreakpointProxy
|
|
7
|
-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
8
|
-
<BreakpointContent
|
|
9
|
-
shouldBeEnabled = "No"
|
|
10
|
-
ignoreCount = "0"
|
|
11
|
-
continueAfterRunningActions = "No"
|
|
12
|
-
filePath = "PluginTests/PluginTests.swift"
|
|
13
|
-
timestampString = "539031493.297595"
|
|
14
|
-
startingColumnNumber = "9223372036854775807"
|
|
15
|
-
endingColumnNumber = "9223372036854775807"
|
|
16
|
-
startingLineNumber = "28"
|
|
17
|
-
endingLineNumber = "28"
|
|
18
|
-
landmarkName = "testEcho()"
|
|
19
|
-
landmarkType = "7">
|
|
20
|
-
</BreakpointContent>
|
|
21
|
-
</BreakpointProxy>
|
|
22
|
-
</Breakpoints>
|
|
23
|
-
</Bucket>
|
package/ios/Plugin/Plugin.xcworkspace/xcuserdata/stewan.xcuserdatad/UserInterfaceState.xcuserstate
DELETED
|
Binary file
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>BNDL</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>1</string>
|
|
21
|
-
</dict>
|
|
22
|
-
</plist>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//import XCTest
|
|
2
|
-
//import Capacitor
|
|
3
|
-
//@testable import Plugin
|
|
4
|
-
//
|
|
5
|
-
//class PluginTests: XCTestCase {
|
|
6
|
-
//
|
|
7
|
-
// override func setUp() {
|
|
8
|
-
// super.setUp()
|
|
9
|
-
// // Put setup code here. This method is called before the invocation of each test method in the class.
|
|
10
|
-
// }
|
|
11
|
-
//
|
|
12
|
-
// override func tearDown() {
|
|
13
|
-
// // Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
14
|
-
// super.tearDown()
|
|
15
|
-
// }
|
|
16
|
-
//
|
|
17
|
-
// func testEcho() {
|
|
18
|
-
// // This is an example of a functional test case for a plugin.
|
|
19
|
-
// // Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
20
|
-
//
|
|
21
|
-
// let value = "Hello, World!"
|
|
22
|
-
// let plugin = MyPlugin()
|
|
23
|
-
//
|
|
24
|
-
// let call = CAPPluginCall(callbackId: "test", options: [
|
|
25
|
-
// "value": value
|
|
26
|
-
// ], success: { (result, call) in
|
|
27
|
-
// let resultValue = result!.data["value"] as? String
|
|
28
|
-
// XCTAssertEqual(value, resultValue)
|
|
29
|
-
// }, error: { (err) in
|
|
30
|
-
// XCTFail("Error shouldn't have been called")
|
|
31
|
-
// })
|
|
32
|
-
//
|
|
33
|
-
// plugin.echo(call!)
|
|
34
|
-
// }
|
|
35
|
-
//}
|
package/ios/Plugin/Podfile
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Uncomment the next line to define a global platform for your project
|
|
2
|
-
platform :ios, '13.0'
|
|
3
|
-
|
|
4
|
-
def capacitor_pods
|
|
5
|
-
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
|
|
6
|
-
use_frameworks!
|
|
7
|
-
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
|
|
8
|
-
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
target 'Plugin' do
|
|
12
|
-
# Pods for IonicRunner
|
|
13
|
-
pod 'Firebase/Messaging', '8.1.1'
|
|
14
|
-
capacitor_pods
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
target 'PluginTests' do
|
|
18
|
-
pod 'Firebase/Messaging', '8.1.1'
|
|
19
|
-
capacitor_pods
|
|
20
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|