From f1e7435932fe33d3b64545279fcefe81a7544594 Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Sun, 11 Oct 2015 16:48:43 -0400 Subject: local notification fix --- www/js/EventServer.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'www/js/EventServer.js') diff --git a/www/js/EventServer.js b/www/js/EventServer.js index e5e30f1a..1c7f7c01 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -64,7 +64,7 @@ angular.module('zmApp.controllers') } - var localNotText = "New Alarms:"; + var localNotText = "New Alarms: "; if (str.status == 'Success' && str.events) // new events { var eventsToDisplay=[]; @@ -93,7 +93,7 @@ angular.module('zmApp.controllers') ZMDataModel.zmDebug("App is in background, displaying localNotification"); localNotificationId--; - if ( localNotificationId == 0) // only slow last 5 + if ( localNotificationId == 0) // only show last 5 { localNotificationId = 5; @@ -101,9 +101,11 @@ angular.module('zmApp.controllers') if ($cordovaLocalNotification.isPresent(localNotificationId)) { - $cordovaLocalNotification.clear(localNotificationId); + ZMDataModel.zmDebug("Cancelling notification ID " + localNotificationId); + $cordovaLocalNotification.cancel(localNotificationId); } - + + ZMDataModel.zmDebug("Creating notification ID " + localNotificationId + " with " +localNotText); $cordovaLocalNotification.schedule({ id: localNotificationId, title: 'ZoneMinder Alarms', @@ -118,11 +120,13 @@ angular.module('zmApp.controllers') } // lets set badge of app irrespective of background or foreground $cordovaBadge.hasPermission().then(function(yes) { - + $cordovaBadge.set($rootScope.alarmCount).then(function() { // You have permission, badge set. + ZMDataModel.zmDebug("Setting badge to " + $rootScope.alarmCount); }, function(err) { // You do not have permission. + ZMDataModel.zmDebug("Error Setting badge to " + $rootScope.alarmCount); }); -- cgit v1.2.3