mirror of https://github.com/BTCPrivate/copay.git
Ref push notification
This commit is contained in:
parent
22824cbe32
commit
fbdfa0016e
|
@ -48,11 +48,16 @@
|
|||
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
|
||||
<div translate>Use Unconfirmed Funds</div>
|
||||
</li>
|
||||
<li ng-show="mobile">
|
||||
<switch id="push-notifications" name="pushNotifications" ng-model="pushNotifications" class="green right"></switch>
|
||||
<div translate>Enable push notifications</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-show="index.usePushNotifications">
|
||||
<h4></h4>
|
||||
<ul class="no-bullet m0">
|
||||
<li>
|
||||
<switch id="push-notifications" name="pushNotifications" ng-model="pushNotifications" class="green right"></switch>
|
||||
<div translate>Enable push notifications</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h4></h4>
|
||||
<ul class="no-bullet m0 ">
|
||||
<li>
|
||||
|
|
|
@ -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 && !self.isWindowsPrhoneApp;
|
||||
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();
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue