changed FCMPlugin to FirebasePlugin

This commit is contained in:
Kadir Sekha 2017-11-10 14:41:02 +09:00
commit 2e11a402f0
2 changed files with 15 additions and 18 deletions

View file

@ -70,10 +70,7 @@
</plugin> </plugin>
<plugin name="cordova-custom-config" spec="~3.0.5" /> <plugin name="cordova-custom-config" spec="~3.0.5" />
<plugin name="cordova-plugin-queries-schemes" spec="~0.1.5" /> <plugin name="cordova-plugin-queries-schemes" spec="~0.1.5" />
<plugin name="cordova-plugin-fcm" spec="https://github.com/cmgustavo/cordova-plugin-fcm.git" /> <plugin name="cordova-plugin-firebase" spec="https://github.com/arnesson/cordova-plugin-firebase.git" />
<!-- Delete cordova-plugin-qrscanner plugin and enable phonegap-plugin-barcodescanner to build cordova windows-->
<!-- <plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/phonegap/phonegap-plugin-barcodescanner.git" /> -->
<!-- Supported Platforms --> <!-- Supported Platforms -->
<engine name="ios" spec="~4.2.1" /> <engine name="ios" spec="~4.2.1" />

View file

@ -11,16 +11,16 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
if (!usePushNotifications || _token) return; if (!usePushNotifications || _token) return;
configService.whenAvailable(function(config) { configService.whenAvailable(function(config) {
if (!config.pushNotificationsEnabled) return; 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. //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); $log.debug('Get token for push notifications: ' + token);
_token = token; _token = token;
root.enable(); root.enable();
}); });
}); });
}; };
root.updateSubscription = function(walletClient) { root.updateSubscription = function(walletClient) {
@ -87,10 +87,10 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
}); });
if (!wallet) return; if (!wallet) return;
if (!wallet.isComplete()) { if (!wallet.isComplete()) {
return $state.go('tabs.copayers', { return $state.go('tabs.copayers', {
walletId: wallet.id walletId: wallet.id
}); });
} }
@ -100,19 +100,19 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
}; };
if (usePushNotifications) { if (usePushNotifications) {
FCMPlugin.onTokenRefresh(function(token) { FirebasePlugin.onTokenRefresh(function(token) {
if (!_token) return; if (!_token) return;
$log.debug('Refresh and update token for push notifications...'); $log.debug('Refresh and update token for push notifications...');
_token = token; _token = token;
root.enable(); root.enable();
}); });
FCMPlugin.onNotification(function(data) { FirebasePlugin.onNotificationOpen(function(data) {
if (!_token) return; if (!_token) return;
$log.debug('New Event Push onNotification: ' + JSON.stringify(data)); $log.debug('New Event Push onNotification: ' + JSON.stringify(data));
if(data.wasTapped) { if(data.tap) {
// Notification was received on device tray and tapped by the user. // Notification was received on device tray and tapped by the user.
var walletIdHashed = data.walletId; var walletIdHashed = data.walletId;
if (!walletIdHashed) return; if (!walletIdHashed) return;
$ionicHistory.nextViewOptions({ $ionicHistory.nextViewOptions({
@ -128,10 +128,10 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
}); });
} else { } else {
// TODO // 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; return root;