diff --git a/public/views/preferencesGlobal.html b/public/views/preferencesGlobal.html
index 9ab5e9878..d690ca4cf 100644
--- a/public/views/preferencesGlobal.html
+++ b/public/views/preferencesGlobal.html
@@ -48,11 +48,16 @@
Use Unconfirmed Funds
-
-
- Enable push notifications
-
+
-
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js
index 4f5c44b7a..af458e8a0 100644
--- a/src/js/controllers/index.js
+++ b/src/js/controllers/index.js
@@ -5,20 +5,21 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var SOFT_CONFIRMATION_LIMIT = 12;
self.isCordova = isCordova;
self.isChromeApp = isChromeApp;
- self.usePushNotifications = isMobile.iOS() || isMobile.Android();
self.isSafari = isMobile.Safari();
+ self.isWindowsPhoneApp = isMobile.Windows() && isCordova;
+ self.usePushNotifications = self.isCordova && !isMobile.Windows();
self.onGoingProcess = {};
self.historyShowLimit = 10;
self.updatingTxHistory = {};
self.prevState = 'walletHome';
- document.addEventListener('deviceready', function() {
+ if (self.usePushNotifications) {
storageService.getDeviceToken(function(err, token) {
$timeout(function() {
if (!token) pushNotificationsService.pushNotificationsInit();
}, 5000);
});
- });
+ }
function strip(number) {
return (parseFloat(number.toPrecision(12)));
@@ -1285,6 +1286,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
$rootScope.$on('Local/SubscribeNotifications', function(event) {
+ if (!self.usePushNotifications) return;
pushNotificationsService.enableNotifications();
diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js
index 046d4e6da..ce69f5903 100644
--- a/src/js/controllers/preferences.js
+++ b/src/js/controllers/preferences.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesController',
- function($scope, $rootScope, $timeout, $log, configService, profileService) {
+ function($scope, $rootScope, $timeout, $log, configService, profileService, txSignService) {
var fc = profileService.focusedClient;
$scope.deleted = false;
@@ -75,7 +75,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
};
opts.touchIdFor[walletId] = newVal;
- $rootScope.$emit('Local/RequestTouchid', function(err) {
+ txSignService.setTouchId(function(err) {
if (err) {
$log.debug(err);
$timeout(function() {
diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js
index 86c3a2b88..5d5a04238 100644
--- a/src/js/controllers/preferencesGlobal.js
+++ b/src/js/controllers/preferencesGlobal.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesGlobalController',
- function($scope, $rootScope, $log, configService, isMobile, uxLanguage, pushNotificationsService) {
+ function($scope, $rootScope, $log, configService, uxLanguage, pushNotificationsService) {
this.init = function() {
var config = configService.getSync();
@@ -17,9 +17,6 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
$scope.pushNotifications = config.pushNotifications.enabled;
};
- if (isMobile.Android() || isMobile.iOS()) $scope.mobile = true;
- else $scope.mobile = false;
-
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
diff --git a/src/js/services/configService.js b/src/js/services/configService.js
index 0d8484ac9..f0ba0397c 100644
--- a/src/js/services/configService.js
+++ b/src/js/services/configService.js
@@ -87,6 +87,9 @@ angular.module('copayApp.services').factory('configService', function(storageSer
if (!configCache.glidera) {
configCache.glidera = defaultConfig.glidera;
}
+ if (!configCache.pushNotifications) {
+ configCache.pushNotifications = defaultConfig.pushNotifications;
+ }
} else {
configCache = lodash.clone(defaultConfig);
diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js
index a5f726582..128c74dc4 100644
--- a/src/js/services/pushNotificationsService.js
+++ b/src/js/services/pushNotificationsService.js
@@ -1,9 +1,9 @@
'use strict';
angular.module('copayApp.services')
- .factory('pushNotificationsService', function($http, $log, isMobile, profileService, storageService, configService, lodash) {
+ .factory('pushNotificationsService', function($http, $log, isMobile, profileService, storageService, configService, lodash, isCordova) {
var root = {};
var defaults = configService.getDefaults();
- var usePushNotifications = isMobile.iOS() || isMobile.Android();
+ var usePushNotifications = isCordova && !isMobile.Windows();
root.pushNotificationsInit = function() {
if (!usePushNotifications) return;
diff --git a/src/js/services/txSignService.js b/src/js/services/txSignService.js
index fb71cf289..43984750b 100644
--- a/src/js/services/txSignService.js
+++ b/src/js/services/txSignService.js
@@ -2,7 +2,6 @@
angular.module('copayApp.services').factory('txSignService', function($rootScope, profileService, gettextCatalog, lodash, trezor, ledger, configService, bwsError, $log) {
var root = {};
- var config = configService.getSync();
var reportSigningStatus = function(opts) {
if (!opts.reporterFn) return;
@@ -41,17 +40,26 @@ angular.module('copayApp.services').factory('txSignService', function($rootScope
return cb();
},
function(msg) {
- $log.debug('Touch ID Failed:' + msg);
- return cb(gettext('Touch ID Failed:') + msg);
+ $log.debug('Touch ID Failed:' + JSON.stringify(msg));
+ return cb(gettextCatalog.getString('Touch ID Failed') + ': ' + msg.localizedDescription);
}
);
} catch (e) {
- $log.debug('Touch ID Failed:' + e);
- return cb(gettext('Touch ID Failed:') + e);
+ $log.debug('Touch ID Failed:' + JSON.stringify(e));
+ return cb(gettextCatalog.getString('Touch ID Failed'));
};
};
+ root.setTouchId = function(cb) {
+ if (window.touchidAvailable) {
+ requestTouchId(cb);
+ } else {
+ return cb();
+ }
+ };
+
root.checkTouchId = function(cb) {
+ var config = configService.getSync();
var fc = profileService.focusedClient;
config.touchIdFor = config.touchIdFor || {};
if (window.touchidAvailable && config.touchIdFor[fc.credentials.walletId]) {