Update badge with push notification while app in background

Since push notification are handled by iOS and not your app you can’t change the application badge on receiving a push notification.

But you can send the badge number in the payload of the push notification, but the you will have to do the calculation server side.

You should read Local and Push Notification Programming Guide and especially the The Notification Payload.

The payload could look like this:

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9
    }
}

Now the app application badge icon will show 9.

Leave a Comment