Merge pull request #4035 from gabrielbazan7/fix/PNDisabled

If pn was not enabled by user, do not show pn switch in IOS
This commit is contained in:
Gustavo Maximiliano Cortez 2016-04-11 13:35:48 -03:00
commit 9357c9c1e3
3 changed files with 26 additions and 5 deletions

View File

@ -97,6 +97,9 @@ if [ ! -d $PROJECT ]; then
cordova plugin add cordova-plugin-globalization
checkOK
cordova plugin add cordova.plugins.diagnostic
checkOK
cordova plugin add cordova-plugin-splashscreen
checkOK
@ -190,7 +193,7 @@ if [ $CURRENT_OS == "ANDROID" ]; then
# cp android/AndroidManifest.xml $PROJECT/platforms/android/AndroidManifest.xml
# checkOK
cp android/build-extras.gradle $PROJECT/platforms/android/build-extras.gradle
checkOK
@ -243,5 +246,3 @@ if [ $CURRENT_OS == "WP8" ]; then
checkOK
fi
fi

View File

@ -48,7 +48,7 @@
<div translate>Use Unconfirmed Funds</div>
</li>
</ul>
<div ng-show="prefGlobal.usePushNotifications">
<div ng-show="prefGlobal.usePushNotifications && PNEnabledByUser">
<h4></h4>
<ul class="no-bullet m0">
<li>
@ -78,7 +78,12 @@
<div translate>About Copay</div>
</li>
</ul>
<div ng-show="prefGlobal.usePushNotifications && !PNEnabledByUser && isIOS">
<div class="text-centered text-gray size-12 m10" translate>Push notifications for Copay are currently disabled. Enable them in the Settings app.</div>
<ul class="no-bullet m0" ng-click="prefGlobal.openSettings()">
<li ng-style="{'color':index.backgroundColor}" translate>Open Settings app</li>
</ul>
</div>
<h4></h4>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -14,12 +14,27 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
this.feeOpts = feeService.feeOpts;
this.currentFeeLevel = feeService.getCurrentFeeLevel();
this.usePushNotifications = isCordova && !isMobile.Windows();
$scope.PNEnabledByUser = true;
$scope.isIOS = isMobile.iOS();
if (!typeof cordova.plugins.diagnostic != undefined && $scope.isIOS) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
});
}
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.glideraTestnet = config.glidera.testnet;
$scope.pushNotifications = config.pushNotifications.enabled;
};
this.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
}
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {