add push notification registration event
This commit is contained in:
parent
e19ece08c7
commit
426d8d29b0
2 changed files with 9 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (self.usePushNotifications) {
|
if (self.usePushNotifications) {
|
||||||
storageService.getDeviceToken(function(err, token) {
|
storageService.getDeviceToken(function(err, token) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
if (!token) pushNotificationsService.pushNotificationsInit(profileService.walletClients);
|
if (!token) pushNotificationsService.pushNotificationsInit();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1293,6 +1293,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$rootScope.$on('Local/pushNotificationsRegistration', function(event) {
|
||||||
|
var config = configService.getSync();
|
||||||
|
if (self.usePushNotifications && config.pushNotifications.enabled)
|
||||||
|
pushNotificationsService.enableNotifications(profileService.walletClients);
|
||||||
|
});
|
||||||
|
|
||||||
self.debouncedUpdate = lodash.throttle(function() {
|
self.debouncedUpdate = lodash.throttle(function() {
|
||||||
self.updateAll({
|
self.updateAll({
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ angular.module('copayApp.services')
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var usePushNotifications = isCordova && !isMobile.Windows();
|
var usePushNotifications = isCordova && !isMobile.Windows();
|
||||||
|
|
||||||
root.pushNotificationsInit = function(walletClients) {
|
root.pushNotificationsInit = function() {
|
||||||
if (!usePushNotifications) return;
|
if (!usePushNotifications) return;
|
||||||
|
|
||||||
var push = PushNotification.init(defaults.pushNotifications.config);
|
var push = PushNotification.init(defaults.pushNotifications.config);
|
||||||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.services')
|
||||||
push.on('registration', function(data) {
|
push.on('registration', function(data) {
|
||||||
$log.debug('Starting push notification registration');
|
$log.debug('Starting push notification registration');
|
||||||
storageService.setDeviceToken(data.registrationId, function() {
|
storageService.setDeviceToken(data.registrationId, function() {
|
||||||
root.enableNotifications(walletsClients);
|
$rootScope.$emit('Local/pushNotificationsRegistration');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue