diff options
| -rw-r--r-- | www/js/EventServer.js | 4 | ||||
| -rw-r--r-- | www/js/EventServerSettingsCtrl.js | 32 |
2 files changed, 30 insertions, 6 deletions
diff --git a/www/js/EventServer.js b/www/js/EventServer.js index de72197b..b9182b6f 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -259,9 +259,9 @@ angular.module('zmApp.controllers') // Send an arbitrary object to the Event Serve // currently planned to use it for device token //-------------------------------------------------------------------------- - function sendMessage(type, obj) { + function sendMessage(type, obj, isForce) { var ld = ZMDataModel.getLogin(); - if (ld.isUseEventServer == "0") { + if (ld.isUseEventServer == "0" && isForce!=1) { ZMDataModel.zmDebug("Not sending WSS message as event server is off"); return; } diff --git a/www/js/EventServerSettingsCtrl.js b/www/js/EventServerSettingsCtrl.js index 67654dff..17da1a37 100644 --- a/www/js/EventServerSettingsCtrl.js +++ b/www/js/EventServerSettingsCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', 'EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', '$ionicPlatform','$ionicPopup', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel, $ionicPlatform, $ionicPopup) { +angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', 'EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', '$ionicPlatform','$ionicPopup', '$timeout', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel, $ionicPlatform, $ionicPopup, $timeout) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; @@ -151,14 +151,17 @@ angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', $scope.loginData.isUseEventServer = ($scope.check.isUseEventServer) ? "1" : "0"; $scope.loginData.disablePush = ($scope.check.disablePush) ? "1" : "0"; + + + - ZMDataModel.setLogin($scope.loginData); + //console.log("**** EVENT MONSTRING " + monstring); //console.log("**** EVENT INTERVALSTRING " + intervalstring); var pushstate = "enabled"; - if ($scope.loginData.disablePush == "1") + if ($scope.loginData.disablePush == "1" || $scope.loginData.isUseEventServer=="0") pushstate = "disabled"; if ($scope.loginData.isUseEventServer=="1") { @@ -194,8 +197,29 @@ angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', } else { - EventServer.disconnect(); + if ($rootScope.apnsToken !="") + // if its defined then this is post init work + // so lets transmit state here + + { + // we need to disable the token + ZMDataModel.zmDebug("Sending token state "+pushstate); + EventServer.sendMessage('push', + { + type:'token', + platform:plat, + token:$rootScope.apnsToken, + state:pushstate + },1); + + } + // Give the above some time to transmit + $timeout (function() { + EventServer.disconnect();ZMDataModel.setLogin($scope.loginData);},3000); } + + + ZMDataModel.displayBanner('info', ['settings saved']); } |
