Fix if push is not available
This commit is contained in:
parent
ee5b2817d7
commit
cd0e5df447
3 changed files with 16 additions and 4 deletions
|
|
@ -13,9 +13,13 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
||||||
$scope.PNEnabledByUser = true;
|
$scope.PNEnabledByUser = true;
|
||||||
$scope.isIOSApp = isIOS && isCordova;
|
$scope.isIOSApp = isIOS && isCordova;
|
||||||
if ($scope.isIOSApp) {
|
if ($scope.isIOSApp) {
|
||||||
PushNotification.hasPermission(function(data) {
|
try {
|
||||||
$scope.PNEnabledByUser = data.isEnabled;
|
PushNotification.hasPermission(function(data) {
|
||||||
});
|
$scope.PNEnabledByUser = data.isEnabled;
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
$log.error(e);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.pushNotifications = {
|
$scope.pushNotifications = {
|
||||||
|
|
@ -24,6 +28,7 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.pushNotificationsChange = function() {
|
$scope.pushNotificationsChange = function() {
|
||||||
|
if (!$scope.pushNotifications) return;
|
||||||
var opts = {
|
var opts = {
|
||||||
pushNotifications: {
|
pushNotifications: {
|
||||||
enabled: $scope.pushNotifications.value
|
enabled: $scope.pushNotifications.value
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,8 @@ angular.module('copayApp.services')
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var push = pushNotificationsService.init(root.wallet);
|
var push = pushNotificationsService.init(root.wallet);
|
||||||
|
|
||||||
|
if (!push) return;
|
||||||
|
|
||||||
push.on('notification', function(data) {
|
push.on('notification', function(data) {
|
||||||
if (!data.additionalData.foreground) {
|
if (!data.additionalData.foreground) {
|
||||||
$log.debug('Push notification event: ', data.message);
|
$log.debug('Push notification event: ', data.message);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,12 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.init = function(walletsClients) {
|
root.init = function(walletsClients) {
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var push = PushNotification.init(defaults.pushNotifications.config);
|
try {
|
||||||
|
var push = PushNotification.init(defaults.pushNotifications.config);
|
||||||
|
} catch(e) {
|
||||||
|
$log.error(e);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
push.on('registration', function(data) {
|
push.on('registration', function(data) {
|
||||||
$log.debug('Starting push notification registration');
|
$log.debug('Starting push notification registration');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue