unsubscribe method refactor

This commit is contained in:
Gabriel Bazán 2016-01-15 17:09:50 -03:00
commit 58b573ac4e
3 changed files with 42 additions and 35 deletions

View file

@ -1288,10 +1288,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
pushNotificationsService.enableNotifications();
});
$rootScope.$on('Local/UnsubscribeNotifications', function(event) {
pushNotificationsService.unsubscribe(null, function(err, response) {
if (err) $log.warn('Error: ' + err.code);
$log.debug('Unsubscribed: ' + response);
$rootScope.$on('Local/UnsubscribeNotifications', function(event, walletId, cb) {
storageService.getDeviceToken(function(err, token) {
pushNotificationsService.unsubscribe(token, walletId, function(err, response) {
if (err) $log.warn('Error: ' + err.code);
$log.debug('Unsubscribed: ' + response);
return cb();
});
});
});