How do you clear iOS Push notification badges (Ionic Push v2 Beta migration)


#1

Hey all,

So I am in a bit of a situation right now, I just recently finished migrating from the v1 Ionic Push to v2 (Beta), and I have everything working, tokens registering, production security profiles, able to receive push notifications to an Adhoc distribution version of my iOS app, so that is all great.

My only problem right now is no matter what I try I cannot get the “Badges” of the push notifications to clear. I took a look at the plugin page here:

(https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md)

And it looks as if you should be able to just pass a “clearBadge”:“true” in the Push obj initialization, so in my app.js file inside of $ionicPlatform.ready() I have placed the following initialization block.

  var push = new Ionic.Push({
            "pluginConfig": {
                  "ios": {
                    "sound": "true",
                    "alert": "true",
                    "badge": "true",
                    "clearBadge": "true"
                  }
                }
            });

So from my understanding, and from the documentation found here (control + f for clearBadge)

(https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions)

This should then, quoted: “Optional. If true the badge will be cleared on app startup.”

But that does not seem to be happening at all, and I know that the push is still working as I am able to register device tokens and send push notifications to the device and receive them. I have tried sending a new notification with a higher badge count, received it properly, and now I can’t get rid of the badge either.

Is there something that I am missing here? Am I initializing the Push object strangely? I can’t seem to figure this out from the Ionic docs or from the push plugin docs. I am sure that I am missing something pretty simple. Once I am able to make all badges clear upon app startup I will be done with this migration and not have to worry about this anymore.

Really appreciate the help in advance!


Doubts ionic cloud push in iOS with Badge
#2

Resolved this issue.

This was all user error, the Push object was being setup in another part of my app without the “clearBadge”: “true” flag being set within it.

Removed that second object setup and everything works well.


#3

Hi @parchambeau,
I see your code, you set that “badge”: true.
I do the same but on iOS device, count number of notification is always 1, it don’t increase.
What should I do to increase count on icon app?
Thanks!