delete response in unsubscribe method
This commit is contained in:
parent
a53ba1fea0
commit
6be5209fcf
2 changed files with 11 additions and 16 deletions
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue