From 2e11a402f0f3d1f179ccfa9e6c7ed1783745f33c Mon Sep 17 00:00:00 2001 From: Kadir Sekha Date: Fri, 10 Nov 2017 14:41:02 +0900 Subject: [PATCH] changed FCMPlugin to FirebasePlugin --- app-template/config-template.xml | 5 +--- src/js/services/pushNotificationsService.js | 28 ++++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app-template/config-template.xml b/app-template/config-template.xml index a6cee216c..974aa0551 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -70,10 +70,7 @@ - - - - + diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js index 5627dea31..756bb7f98 100644 --- a/src/js/services/pushNotificationsService.js +++ b/src/js/services/pushNotificationsService.js @@ -11,16 +11,16 @@ angular.module('copayApp.services').factory('pushNotificationsService', function if (!usePushNotifications || _token) return; configService.whenAvailable(function(config) { if (!config.pushNotificationsEnabled) return; - - $log.debug('Starting push notification registration...'); + + $log.debug('Starting push notification registration...'); //Keep in mind the function will return null if the token has not been established yet. - FCMPlugin.getToken(function(token) { + FirebasePlugin.getToken(function(token) { $log.debug('Get token for push notifications: ' + token); _token = token; root.enable(); - }); - }); + }); + }); }; root.updateSubscription = function(walletClient) { @@ -87,10 +87,10 @@ angular.module('copayApp.services').factory('pushNotificationsService', function }); if (!wallet) return; - + if (!wallet.isComplete()) { return $state.go('tabs.copayers', { - walletId: wallet.id + walletId: wallet.id }); } @@ -100,19 +100,19 @@ angular.module('copayApp.services').factory('pushNotificationsService', function }; if (usePushNotifications) { - - FCMPlugin.onTokenRefresh(function(token) { + + FirebasePlugin.onTokenRefresh(function(token) { if (!_token) return; $log.debug('Refresh and update token for push notifications...'); _token = token; root.enable(); }); - FCMPlugin.onNotification(function(data) { + FirebasePlugin.onNotificationOpen(function(data) { if (!_token) return; $log.debug('New Event Push onNotification: ' + JSON.stringify(data)); - if(data.wasTapped) { - // Notification was received on device tray and tapped by the user. + if(data.tap) { + // Notification was received on device tray and tapped by the user. var walletIdHashed = data.walletId; if (!walletIdHashed) return; $ionicHistory.nextViewOptions({ @@ -128,10 +128,10 @@ angular.module('copayApp.services').factory('pushNotificationsService', function }); } else { // TODO - // Notification was received in foreground. Maybe the user needs to be notified. + // Notification was received in foreground. Maybe the user needs to be notified. } }); - } + } return root;