Incrementing badge count for push notifications


#1

Hello!

I’m sending push notifications on my backend and having some good success so far.

My handling on the app side is pretty simple, I just show up a local alert.

And for iOS, I set the badge count to 0, when the notification origin is either ‘selected’ or ‘received’.

Right now however, I only seem to be able to increment the badge count by 1 in the ‘badge’ property sent with the push notification object on the server.

So the badge count is only ever 1 or 0.

Is there any way I can just increment the badge count by 1 when I send the push notification? If not, how else would I be able to do this?

Thank you


#2

Hi @judgejab, the badge count field in the notification payload is an absolute number, not a delta. Are you ever setting the badge count to a number other than 0 or 1?


#3

Hey @ide,

I’m not, though I’m not sure how I would be able to ever do anything but that?

If my handleNotifications function in my app was to use something like:

getBadgeNumberAsync().then(count => setBadgeNumberAsync(number + 1)

How would this code ever be run if the app was closed?

I want to clear all notifications as soon as the user opens the app as they’ll be shown all of them upon opening.

Thanks