From e4f01f9901bd274607dc0e0ee7caff9fa347d12e Mon Sep 17 00:00:00 2001 From: Hardik Thakkar Date: Wed, 24 May 2017 19:37:26 +0530 Subject: [PATCH 01/15] prepare methods --- README.md | 7 +++++++ package.json | 2 +- plugin.xml | 2 +- src/android/FirebasePlugin.java | 16 ++++++++++++++++ src/ios/FirebasePlugin.h | 1 + src/ios/FirebasePlugin.m | 6 ++++++ www/firebase.js | 4 ++++ 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bffd760a5..e525aa080 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,13 @@ Unsubscribe from a topic: window.FirebasePlugin.unsubscribe("example"); ``` +### unregister + +Unregister from firebase, used to stop receiving push notifications. Call this when you logout user from your app. : +``` +window.FirebasePlugin.unregister(); +``` + ### logEvent Log an event using Analytics: diff --git a/package.json b/package.json index 76a657082..c9c2e7ad7 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/arnesson/cordova-plugin-firebase" }, "name": "cordova-plugin-firebase", - "version": "0.1.21", + "version": "0.1.22", "description": "Cordova plugin for Google Firebase", "cordova": { "id": "cordova-plugin-firebase", diff --git a/plugin.xml b/plugin.xml index 7cf5b5aae..78687103e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - Google Firebase Plugin diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java index c986ec6fe..69f37402f 100755 --- a/src/android/FirebasePlugin.java +++ b/src/android/FirebasePlugin.java @@ -87,6 +87,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo } else if (action.equals("unsubscribe")) { this.unsubscribe(callbackContext, args.getString(0)); return true; + } else if (action.equals("unregister")) { + this.unregister(callbackContext); + return true; } else if (action.equals("onNotificationOpen")) { this.onNotificationOpen(callbackContext); return true; @@ -340,6 +343,19 @@ public void run() { }); } + private void unregister(final CallbackContext callbackContext) { + cordova.getThreadPool().execute(new Runnable() { + public void run() { + try { + //TODO + callbackContext.success(); + } catch (Exception e) { + callbackContext.error(e.getMessage()); + } + } + }); + } + private void logEvent(final CallbackContext callbackContext, final String name, final JSONObject params) throws JSONException { final Bundle bundle = new Bundle(); Iterator iter = params.keys(); diff --git a/src/ios/FirebasePlugin.h b/src/ios/FirebasePlugin.h index a88ce4522..93542737c 100755 --- a/src/ios/FirebasePlugin.h +++ b/src/ios/FirebasePlugin.h @@ -11,6 +11,7 @@ - (void)getBadgeNumber:(CDVInvokedUrlCommand*)command; - (void)subscribe:(CDVInvokedUrlCommand*)command; - (void)unsubscribe:(CDVInvokedUrlCommand*)command; +- (void)unregister:(CDVInvokedUrlCommand*)command; - (void)onNotificationOpen:(CDVInvokedUrlCommand*)command; - (void)onTokenRefresh:(CDVInvokedUrlCommand*)command; - (void)sendNotification:(NSDictionary*)userInfo; diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m index d7dbf788d..f604a4283 100644 --- a/src/ios/FirebasePlugin.m +++ b/src/ios/FirebasePlugin.m @@ -144,6 +144,12 @@ - (void)unsubscribe:(CDVInvokedUrlCommand *)command { [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } +- (void)unregister:(CDVInvokedUrlCommand *)command { + //TODO + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + - (void)onNotificationOpen:(CDVInvokedUrlCommand *)command { self.notificationCallbackId = command.callbackId; diff --git a/www/firebase.js b/www/firebase.js index 4d350b8c3..cf67c8846 100644 --- a/www/firebase.js +++ b/www/firebase.js @@ -40,6 +40,10 @@ exports.unsubscribe = function(topic, success, error) { exec(success, error, "FirebasePlugin", "unsubscribe", [topic]); }; +exports.unregister = function(success, error) { + exec(success, error, "FirebasePlugin", "unregister", []); +}; + exports.logEvent = function(name, params, success, error) { exec(success, error, "FirebasePlugin", "logEvent", [name, params]); }; From 72e5987ff84415daf46e1d923e3b2d22a3d79144 Mon Sep 17 00:00:00 2001 From: Hardik Thakkar Date: Fri, 26 May 2017 17:59:40 +0530 Subject: [PATCH 02/15] completed for iOS --- src/ios/FirebasePlugin.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m index f604a4283..9d0a7a6a1 100644 --- a/src/ios/FirebasePlugin.m +++ b/src/ios/FirebasePlugin.m @@ -145,9 +145,18 @@ - (void)unsubscribe:(CDVInvokedUrlCommand *)command { } - (void)unregister:(CDVInvokedUrlCommand *)command { - //TODO - CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + [[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error){ + if (error) { + NSLog(@"Unable to delete instance"); + } else { + NSString* currentToken = [[FIRInstanceID instanceID] token]; + if (currentToken != nil) { + [self sendToken:currentToken]; + } + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; } - (void)onNotificationOpen:(CDVInvokedUrlCommand *)command { From 3f5618fe6e3ea54ef2fcba1d9e1f1fd0980aae8e Mon Sep 17 00:00:00 2001 From: Hardik Thakkar Date: Fri, 26 May 2017 18:04:27 +0530 Subject: [PATCH 03/15] completed for Android --- src/android/FirebasePlugin.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java index 69f37402f..c0d501e9a 100755 --- a/src/android/FirebasePlugin.java +++ b/src/android/FirebasePlugin.java @@ -347,7 +347,11 @@ private void unregister(final CallbackContext callbackContext) { cordova.getThreadPool().execute(new Runnable() { public void run() { try { - //TODO + FirebaseInstanceId.deleteInstanceId(); + String currentToken = FirebaseInstanceId.getInstance().getToken(); + if (currentToken != null) { + FirebasePlugin.sendToken(currentToken); + } callbackContext.success(); } catch (Exception e) { callbackContext.error(e.getMessage()); From a5fad5d00f7bd6c3bb828d76ca4af38a020b7e09 Mon Sep 17 00:00:00 2001 From: hardikthakkar3 Date: Mon, 29 May 2017 13:49:26 +0530 Subject: [PATCH 04/15] Update FirebasePlugin.java Build Error Resolved --- src/android/FirebasePlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java index c0d501e9a..a8867b13a 100755 --- a/src/android/FirebasePlugin.java +++ b/src/android/FirebasePlugin.java @@ -347,7 +347,7 @@ private void unregister(final CallbackContext callbackContext) { cordova.getThreadPool().execute(new Runnable() { public void run() { try { - FirebaseInstanceId.deleteInstanceId(); + FirebaseInstanceId.getInstance().deleteInstanceId(); String currentToken = FirebaseInstanceId.getInstance().getToken(); if (currentToken != null) { FirebasePlugin.sendToken(currentToken); From ece1e7537c0ce738cd204a72db41033cabcf9674 Mon Sep 17 00:00:00 2001 From: Hardik Thakkar Date: Tue, 30 May 2017 16:29:38 +0530 Subject: [PATCH 05/15] Version number change reverted --- package.json | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c9c2e7ad7..76a657082 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/arnesson/cordova-plugin-firebase" }, "name": "cordova-plugin-firebase", - "version": "0.1.22", + "version": "0.1.21", "description": "Cordova plugin for Google Firebase", "cordova": { "id": "cordova-plugin-firebase", diff --git a/plugin.xml b/plugin.xml index 78687103e..7cf5b5aae 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - Google Firebase Plugin From fb6a8707b6fefdbdad83a940ee5ac6f8e9333972 Mon Sep 17 00:00:00 2001 From: Thomas Alrek Date: Fri, 9 Jun 2017 13:14:42 +0200 Subject: [PATCH 06/15] setAnalyticsCollectionEnabled --- src/android/FirebasePlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java index a8867b13a..7e4431dfa 100755 --- a/src/android/FirebasePlugin.java +++ b/src/android/FirebasePlugin.java @@ -51,6 +51,7 @@ protected void pluginInitialize() { public void run() { Log.d(TAG, "Starting Firebase plugin"); mFirebaseAnalytics = FirebaseAnalytics.getInstance(context); + mFirebaseAnalytics.setAnalyticsCollectionEnabled(true); if (extras != null && extras.size() > 1) { if (FirebasePlugin.notificationStack == null) { FirebasePlugin.notificationStack = new ArrayList(); From e7b0804ff30fac36715d35ec2e399a8e1b5960f1 Mon Sep 17 00:00:00 2001 From: Thomas Alrek Date: Fri, 9 Jun 2017 13:16:35 +0200 Subject: [PATCH 07/15] Add com.google.android.gms.measurement.AppMeasurementService to AndroidManifest --- plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.xml b/plugin.xml index 7cf5b5aae..04b3219c6 100644 --- a/plugin.xml +++ b/plugin.xml @@ -31,6 +31,9 @@ xmlns:android="http://schemas.android.com/apk/res/android"> + + + From b7182e6359423f8539f7957c688c1ab9c3ef4cd0 Mon Sep 17 00:00:00 2001 From: Erik Djupvik Date: Fri, 9 Jun 2017 13:53:38 +0200 Subject: [PATCH 08/15] Moved enabling of AppMeasurementService to /manifest/application --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 04b3219c6..0b0077eef 100644 --- a/plugin.xml +++ b/plugin.xml @@ -31,7 +31,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> - + From f95db665b94d491e36abe349288e129dd45fde7c Mon Sep 17 00:00:00 2001 From: Erik Djupvik Date: Fri, 9 Jun 2017 14:21:52 +0200 Subject: [PATCH 09/15] Fix app crashing when receiving push notification in Android --- plugin.xml | 1 + src/android/colors.xml | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 src/android/colors.xml diff --git a/plugin.xml b/plugin.xml index 04b3219c6..fae5d744e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -52,6 +52,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> + diff --git a/src/android/colors.xml b/src/android/colors.xml new file mode 100644 index 000000000..6f1665a52 --- /dev/null +++ b/src/android/colors.xml @@ -0,0 +1,6 @@ + + + #FFFFFF00 + #FF220022 + #FF00FFFF + \ No newline at end of file From 9eecdf9c814cad4e3588ed23276da1b76b4be438 Mon Sep 17 00:00:00 2001 From: Erik Djupvik Date: Fri, 9 Jun 2017 14:22:23 +0200 Subject: [PATCH 10/15] Copy GoogleService-Info.plist content to all locations required --- scripts/after_prepare.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/after_prepare.js b/scripts/after_prepare.js index ed0250bda..8e77bfadb 100755 --- a/scripts/after_prepare.js +++ b/scripts/after_prepare.js @@ -41,6 +41,7 @@ if (directoryExists("platforms/ios")) { try { var contents = fs.readFileSync(paths[i]).toString(); fs.writeFileSync("platforms/ios/" + name + "/Resources/GoogleService-Info.plist", contents) + fs.writeFileSync("platforms/ios/" + name + "/Resources/Resources/GoogleService-Info.plist", contents) } catch(err) { process.stdout.write(err); } From 087dcfde51c07b8ba84bce557beedaa2227212aa Mon Sep 17 00:00:00 2001 From: wolfg Date: Fri, 23 Jun 2017 20:38:37 +0800 Subject: [PATCH 11/15] Fix #327 The cause is https://github.com/apache/cordova-ios/pull/310/files. --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 7cf5b5aae..667ad2753 100644 --- a/plugin.xml +++ b/plugin.xml @@ -74,7 +74,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> production - + From cb43a20dd5eb99168e1a755ebb657157750e6e12 Mon Sep 17 00:00:00 2001 From: dferreira1 Date: Wed, 28 Jun 2017 16:24:43 -0300 Subject: [PATCH 12/15] added setVisibility VISIBILITY_PUBLIC to show all notifications on lock screen --- src/android/FirebasePluginMessagingService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/android/FirebasePluginMessagingService.java b/src/android/FirebasePluginMessagingService.java index 04b653312..a42ce60e3 100755 --- a/src/android/FirebasePluginMessagingService.java +++ b/src/android/FirebasePluginMessagingService.java @@ -87,6 +87,7 @@ private void sendNotification(String id, String title, String messageBody, Map Date: Tue, 4 Jul 2017 13:18:18 +0200 Subject: [PATCH 13/15] revert 087dcfde51c07b8ba84bce557beedaa2227212aa --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 613e5a52c..e10942842 100644 --- a/plugin.xml +++ b/plugin.xml @@ -78,7 +78,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> production - + From 93d83348e7b988f2d228a551bdb7e72f30520501 Mon Sep 17 00:00:00 2001 From: Robert Arnesson Date: Tue, 4 Jul 2017 13:23:00 +0200 Subject: [PATCH 14/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e525aa080..f317a9e81 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # cordova-plugin-firebase This plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project! -Android and iOS supported (including iOS 10). +Android and iOS supported. ## Installation See npm package for versions - https://www.npmjs.com/package/cordova-plugin-firebase From 174b57d19f54f7155b6dcecb64cd62b5ef4dc731 Mon Sep 17 00:00:00 2001 From: Robert Arnesson Date: Tue, 4 Jul 2017 23:01:13 +0200 Subject: [PATCH 15/15] 0.1.22 --- README.md | 4 ++-- package.json | 2 +- plugin.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f317a9e81..a52fe0504 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ See npm package for versions - https://www.npmjs.com/package/cordova-plugin-fire Install the plugin by adding it your project's config.xml: ``` - + ``` or by running: ``` -cordova plugin add cordova-plugin-firebase@0.1.21 --save +cordova plugin add cordova-plugin-firebase@0.1.22 --save ``` Download your Firebase configuration files, GoogleService-Info.plist for ios and google-services.json for android, and place them in the root folder of your cordova project: diff --git a/package.json b/package.json index 76a657082..c9c2e7ad7 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/arnesson/cordova-plugin-firebase" }, "name": "cordova-plugin-firebase", - "version": "0.1.21", + "version": "0.1.22", "description": "Cordova plugin for Google Firebase", "cordova": { "id": "cordova-plugin-firebase", diff --git a/plugin.xml b/plugin.xml index e10942842..34c87dd96 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - Google Firebase Plugin