From b5d0a7ff085214c3bd0375abe347ff36c729b6b0 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 17 May 2017 16:25:36 -0300 Subject: [PATCH] Subscribe push notifications after create a wallet --- src/js/controllers/create.js | 3 ++- src/js/services/pushNotificationsService.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 8a18d6b2d..5bccde437 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) { + function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService, pushNotificationsService) { /* For compressed keys, m*73 + n*34 <= 496 */ var COPAYER_PAIR_LIMITS = { @@ -214,6 +214,7 @@ angular.module('copayApp.controllers').controller('createController', } walletService.updateRemotePreferences(client); + pushNotificationsService.updateSubscription(client); if ($scope.seedSource.id == 'set') { profileService.setBackupFlag(client.credentials.walletId); diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js index 562cbdc5b..5627dea31 100644 --- a/src/js/services/pushNotificationsService.js +++ b/src/js/services/pushNotificationsService.js @@ -23,6 +23,14 @@ angular.module('copayApp.services').factory('pushNotificationsService', function }); }; + root.updateSubscription = function(walletClient) { + if (!_token) { + $log.warn('Push notifications disabled for this device. Nothing to do here.'); + return; + } + _subscribe(walletClient); + }; + root.enable = function() { if (!_token) { $log.warn('No token available for this device. Cannot set push notifications. Needs registration.');