0
votes

Apps in IOS generally show a badge counter telling how many unread notifications are pending for that app. My understanding is that, to update the badge counter, increment or decrement, we need to send a push notification with the current counter value.

I was testing the behaviour of Gmail app, and even if I mark a message as read on my laptop's browser, the counter on App on IOS got decremented to represent the correct value, without receiving any push notification. I had killed the app on IOS before testing it.

I am wondering how Gmail does that. Can silent push notifications, let us update the app badge counter without showing notification alert? Do silent push notifications work at all, when the app is in killed state?

2

2 Answers

0
votes

You can update your app's badge count by sending the new count from the server. For example by sending:

{
   “aps” : {
      “badge” : 9
   }
}

As the payload you would set the badge to 9.

For more on the APNS payload, you can check the docs

-1
votes

On iOS it doesn't matter if the app is killed or not to receive a push notification (btw, that's why they are push notifications). In order to update the badge number, you can send the Background Notification (silent notification), which wakes your app so that your app can update, fetch new content.

Read the Docs