airpush-notificationair-native-extensionanedistriqt

The Badge number is constantly increasing, even after I use the setBadgeNumber(0) method


I'm using the Distriqt PushNotifications ANE and PARSE to send PushNotifications, and so far everything is working PERFECTLY.

This means, I register my iOS devices and receive PushNotifications as it should be....

When I send PushNotifications with PARSE I use the badge:"Increment" value, which understandably increments the Value By +1.

After I open the App, I want to reset the BADGE to be at 0 and I use the setBadgeNumber(0) method... This also works, I tried with other values like 11, or 1 and it displays it correctly.

The Problem is that when I send another PARSE notification it displays now the old value + 1 !!!

Like so:

How can I really reset the badge?


Solution

  • The value of the badge is actually sent as part of the push notification payload, eg:

    {
        "aps" : {
            "alert" : "Notification content",
            "badge" : 5
        }
    }
    

    You should double check what Parse is actually sending as it will be keeping a count of the notifications and sending that as part of the payload, so you will either need to disable this in Parse or notify Parse of your user resetting / changing the count.

    Calling setBadgeNumber just changes the icon on the application and doesn't update Parse of this change.

    You could look into the Parse ANE which helps out with this process:

    http://airnativeextensions.com/extension/com.distriqt.Parse