diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 18f2eee90..855eaed7a 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -13,8 +13,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.prevState = 'walletHome'; document.addEventListener('deviceready', function() { - if (!self.usePushNotifications) return; - storageService.getDeviceToken(function(err, token) { $timeout(function() { if (!token) pushNotificationsService.pushNotificationsInit(); @@ -1286,18 +1284,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); $rootScope.$on('Local/SubscribeNotifications', function(event) { - if (!self.usePushNotifications) return; pushNotificationsService.enableNotifications(); }); $rootScope.$on('Local/UnsubscribeNotifications', function(event, walletId, cb) { - if (self.usePushNotifications) return cb(); + if (!self.usePushNotifications) return cb(); - pushNotificationsService.unsubscribe(walletId, function(err, response) { - if (err) $log.warn('Error: ' + err.code); - $log.debug('Unsubscribed: ' + response); + pushNotificationsService.unsubscribe(walletId, function(err) { + if (err) $log.warn('Subscription error: ' + err.code); + else $log.debug('Unsubscribed from push notifications service'); return cb(); }); }); diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js index 7f17b024e..2e7292e6b 100644 --- a/src/js/services/pushNotificationsService.js +++ b/src/js/services/pushNotificationsService.js @@ -42,8 +42,8 @@ angular.module('copayApp.services') opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null; opts.token = token; root.subscribe(opts, wallet.id, function(err, response) { - if (err) $log.warn('Error: ' + err.code); - $log.debug('Suscribed to push notifications service: ' + JSON.stringify(response)); + if (err) $log.warn('Subscription error: ' + err.code); + else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response)); }); }); }); @@ -53,15 +53,14 @@ angular.module('copayApp.services') if (!usePushNotifications) return; lodash.forEach(profileService.getWallets('testnet'), function(wallet) { - root.unsubscribe(wallet.id, function(err, response) { - if (err) $log.warn('Error: ' + err.code); - $log.debug('Unsubscribed from push notifications service'); + root.unsubscribe(wallet.id, function(err) { + if (err) $log.warn('Subscription error: ' + err.code); + else $log.debug('Unsubscribed from push notifications service'); }); }); } root.subscribe = function(opts, walletId, cb) { - if (!usePushNotifications) return; var walletClient = profileService.getClient(walletId); walletClient.pushNotificationsSubscribe(opts, function(err, resp) { @@ -71,12 +70,11 @@ angular.module('copayApp.services') } root.unsubscribe = function(walletId, cb) { - if (!usePushNotifications) return; var walletClient = profileService.getClient(walletId); - walletClient.pushNotificationsUnsubscribe(function(err, resp) { + walletClient.pushNotificationsUnsubscribe(function(err) { if (err) return cb(err); - return cb(null, resp); + return cb(null); }); }