App icon badge on push notification


I am trying to get a badge to show up on my app icon when a notification is received. I am using the ionic native push plugin and node-gcm to send the notification.

I can get a badge to show up for IOS by adding a count to the payload. But this doesn’t increase for each push. It just sets the badge number to whatever the number is that is set in the payload.

I can’t get any badge to show for android.

I know there is a badge plugin, but is there a way to get this to run when the app isn’t open?

Anyone have a solution for this? It would be greatly appreciated.

I got the badge showing for android now. But still not sure how to increase the badge number when additional notifications come in. Any ideas?

This exists:

I’m aware of that. I have this plugin install already, but unless i’m missing something there is no way to make it run when the app is closed. This would be necessary to increase when a push is received.

1 Like

Isn’t this native behaviour, at least on iOS?

No, you have to keep a record of unchecked notifications and send the new total with each push. Can also do the same thing with android.

I was hoping there was a way to increase the number without having to store the amount of notifications that had been unchecked, but it doesn’t seem to be the case.

My solution is to keep counter running in each users profile that is cleared any time they open the app. When a push is being processed by node-gcm it gets the number and increases it by 1, stores it and sends it with the notification payload.

What do you mean by [quote=“stevenhastie, post:6, topic:89595”]
unchecked notifications

As far as I remember the default behaviour was that the app started with no badge - then increased badge number +1 for every push you received, then cleared it all when you actually opened the app. Isn’t this the case any more? (Didn’t do default push stuff for a long time)

By unchecked notifications I mean, they haven’t opened the app since receiving the notifications.

Unless i’m missing something it doesn’t show a badge on IOS unless you send a number to be displayed along with the push notification payload.

Hey @stevenhastie ! How did you get the android badges to work ? There is no option like in iOS in the docs.

Thanks !

Just add “badge”:“here goes the value of the badge you want to appear on you app icon”

Hey @quieterkali,
Could you please share the payload structure with the badge.
Thanks in advance.

            var message = {
              to: regIdOfReceiver,
              notification: {
                title: 'Example Title',
                body: 'This is an example push notification',
                sound: "default",
                badge: 1