I'm using the push notification plugin (http://docs.telerik.com/platform/backend-services/javascript/push-notifications/push-getting-started).
Everything is working great so far, I can submit new notifications from the Backend Services REST Api, the notification displays on the device and the app icon badge number is set.
I need to be able to get the badge count and display how many notifications a user has when they log into the app.
I noticed that there are push.setBadgeNumber and push.clearBadgeNumber functions, but there is no push.getBadgeNumber function.
http://docs.telerik.com/platform/backend-services/javascript/apireference/JavascriptSDK/Push/push.setBadgeNumber
I decided to try out the Badge Cordova plugin (http://plugins.telerik.com/cordova/plugin/badge), but it isn't working, it always returns zero, even if the icon has a number.
Here's my code for getting the badge count:
if (window.cordova) {
document.addEventListener("deviceready", function () {
if (navigator && navigator.splashscreen) {
navigator.splashscreen.hide();
}
bootstrap();
if (!window.navigator.simulator) {
window.screen.lockOrientation("portrait");
cordova.plugins.notification.badge.get(function (count) {
console.log("Current badge: " + count);
if (count > 0) {
$("#badgeCount").text(count.toString());
$("#badgeContainer").show();
}
else {
$("#badgeContainer").hide();
}
});
}
}, false);
}
else {
bootstrap();
}
Any suggestions?