Push Notifications - Get Badge Count

Thread is closed for posting
3 posts, 0 answers
  1. Joe
    Joe avatar
    8 posts
    Member since:
    Oct 2016

    Posted 29 Mar 2017 Link to this post

    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.


    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) {
                if (!window.navigator.simulator) {
                    cordova.plugins.notification.badge.get(function (count) {                   
                        console.log("Current badge: " + count);
                        if (count > 0) {
                        else {
            }, false);
        else {

    Any suggestions?


  2. Anton Dobrev
    Anton Dobrev avatar
    609 posts

    Posted 03 Apr 2017 Link to this post

    Hi Joe,

    When sending a push notification to iOS you can set the IOS.aps.badge number in the payload.
    It will be set on the app icon. In the notification received callback you will receive a badge property with the value of the badge at the moment. Make the required calculations and set the device badge count from the app using the methods for controlling the badge count.

    var onNotificationAPN = function(e) {
        var badgeCount = parseInt(e.badge);
        // alter the badge count here

    I hope this helps.

    Anton Dobrev
    Telerik by Progress

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

  3. Joe
    Joe avatar
    8 posts
    Member since:
    Oct 2016

    Posted 03 Apr 2017 in reply to Anton Dobrev Link to this post

    Anton ,

    Thanks a lot, this is exactly what I needed!

Back to Top