i am working with ionic 1 app and implemented push notifications in it. Now i am trying to implement badge on app icon and for that purpose i am using cordova plugin which is (Cordova Badge Plugin ). it is working when push notifications arrives and by clicking on that notification it opens the app and i have implemented badge logic there. i code it like this.
$rootScope.$on(‘cloud:push:notification’, function (event, data) {
document.addEvenLtistener(‘deviceready’, function () {
cordova.plugins.notification.badge.requestPermission(function (granted) {
cordova.plugins.notification.badge.set(10);
});
}, false);
var msg = data.message;
alert(msg.title + ': ’ + msg.text);
});
on closing app it shows badge and when i open app again it clears the badge so i know how actually badge is working. To clear badge i am doing code like this.
document.addEventListener('deviceready', function () {
cordova.plugins.notification.badge.clear();
}, false);
All i want is to app icon to display the badge count when the notification arrives, right now it shows the count but only when i open the app.