Increment push notification badge number

Thread is closed for posting
2 posts, 0 answers
  1. Nader
    Nader avatar
    43 posts
    Member since:
    Jun 2013

    Posted 11 Dec 2014 Link to this post


    I am working on an app that is using the "Telerik Verified" push plugin in AppBuilder. I am able to receive notifications from my server and the app's badge number is set to the value that is received in the payload. The thing is that the badge number never seems to increment automatically when new notifications are received.
    I have looked around for solutions and have even tried setting the badge number to "+1" in the payload, but iOS seems to ignore this value if its being sent as a string. I even tried using the "setApplicationIconBadgeNumber" function but it is not being called while the app is not running.
    The only way I found was to save every device's badge count on the server, which is incremented on the server side, and clear that value every time the app is launched, but I would rather be able to solve this problem on the client side.
    Is there any way I could fix this issue without having to sync each device's notification state with the server?

  2. Anton Dobrev
    Anton Dobrev avatar
    609 posts

    Posted 16 Dec 2014 Link to this post

    Hello Nader,

    Thank you for posting to the Telerik Developer Forums.

    Currently, the badge value is set to the value received in the badge key of the payload. The setApplicationBadgeNumber method in the plugin can be used only when the app is running (for example, to update the badge value).

    With the next release of Telerik Backend Services, expected till the end of the week, you will be able to increment/decrement the current value of the badge with the payload sent from the server. For example, by specifying +1 for the badge, the current value will be incremented with one. Note that the current state is saved in a dedicated field of the device registration on the server.

    To take full benefit from this functionality provided by the server, developers can update the stored badge value for their device from the client app or from a admin app. Whenever the user "responds" to a notification, the app should decrement the badge value on the server by 1 or reset the value of the badge when the app is launched. This solution is up to the developer and should be done programmatically from the client app.

    Please, let me know if you have questions.

    Anton Dobrev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top