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';
|
self.prevState = 'walletHome';
|
||||||
|
|
||||||
document.addEventListener('deviceready', function() {
|
document.addEventListener('deviceready', function() {
|
||||||
if (!self.usePushNotifications) return;
|
|
||||||
|
|
||||||
storageService.getDeviceToken(function(err, token) {
|
storageService.getDeviceToken(function(err, token) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
if (!token) pushNotificationsService.pushNotificationsInit();
|
if (!token) pushNotificationsService.pushNotificationsInit();
|
||||||
|
|
@ -1286,18 +1284,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/SubscribeNotifications', function(event) {
|
$rootScope.$on('Local/SubscribeNotifications', function(event) {
|
||||||
if (!self.usePushNotifications) return;
|
|
||||||
|
|
||||||
pushNotificationsService.enableNotifications();
|
pushNotificationsService.enableNotifications();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/UnsubscribeNotifications', function(event, walletId, cb) {
|
$rootScope.$on('Local/UnsubscribeNotifications', function(event, walletId, cb) {
|
||||||
if (self.usePushNotifications) return cb();
|
if (!self.usePushNotifications) return cb();
|
||||||
|
|
||||||
pushNotificationsService.unsubscribe(walletId, function(err, response) {
|
pushNotificationsService.unsubscribe(walletId, function(err) {
|
||||||
if (err) $log.warn('Error: ' + err.code);
|
if (err) $log.warn('Subscription error: ' + err.code);
|
||||||
$log.debug('Unsubscribed: ' + response);
|
else $log.debug('Unsubscribed from push notifications service');
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ angular.module('copayApp.services')
|
||||||
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
|
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
|
||||||
opts.token = token;
|
opts.token = token;
|
||||||
root.subscribe(opts, wallet.id, function(err, response) {
|
root.subscribe(opts, wallet.id, function(err, response) {
|
||||||
if (err) $log.warn('Error: ' + err.code);
|
if (err) $log.warn('Subscription error: ' + err.code);
|
||||||
$log.debug('Suscribed to push notifications service: ' + JSON.stringify(response));
|
else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -53,15 +53,14 @@ angular.module('copayApp.services')
|
||||||
if (!usePushNotifications) return;
|
if (!usePushNotifications) return;
|
||||||
|
|
||||||
lodash.forEach(profileService.getWallets('testnet'), function(wallet) {
|
lodash.forEach(profileService.getWallets('testnet'), function(wallet) {
|
||||||
root.unsubscribe(wallet.id, function(err, response) {
|
root.unsubscribe(wallet.id, function(err) {
|
||||||
if (err) $log.warn('Error: ' + err.code);
|
if (err) $log.warn('Subscription error: ' + err.code);
|
||||||
$log.debug('Unsubscribed from push notifications service');
|
else $log.debug('Unsubscribed from push notifications service');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
root.subscribe = function(opts, walletId, cb) {
|
root.subscribe = function(opts, walletId, cb) {
|
||||||
if (!usePushNotifications) return;
|
|
||||||
|
|
||||||
var walletClient = profileService.getClient(walletId);
|
var walletClient = profileService.getClient(walletId);
|
||||||
walletClient.pushNotificationsSubscribe(opts, function(err, resp) {
|
walletClient.pushNotificationsSubscribe(opts, function(err, resp) {
|
||||||
|
|
@ -71,12 +70,11 @@ angular.module('copayApp.services')
|
||||||
}
|
}
|
||||||
|
|
||||||
root.unsubscribe = function(walletId, cb) {
|
root.unsubscribe = function(walletId, cb) {
|
||||||
if (!usePushNotifications) return;
|
|
||||||
|
|
||||||
var walletClient = profileService.getClient(walletId);
|
var walletClient = profileService.getClient(walletId);
|
||||||
walletClient.pushNotificationsUnsubscribe(function(err, resp) {
|
walletClient.pushNotificationsUnsubscribe(function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
return cb(null, resp);
|
return cb(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue