Dickens A S
Dickens A S

Reputation: 4054

Will IOS increment a push notfication badge number?

I need to write a application which can show badge number on the icon.

I am able to receive the push notification and the badge number is also getting displayed as 5.

But, when the second push notification received while the app is still not yet launched the badge still displays 5.

It is not supposed to be 10?

Upvotes: 2

Views: 11846

Answers (4)

Fabio Berger
Fabio Berger

Reputation: 1917

The server who sent the notification has to set the number to 10, not you. See here for more information: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1

Upvotes: 2

Grzegorz Krukowski
Grzegorz Krukowski

Reputation: 19802

You can control badge number with aps dictionary attached to push notification. There is a badge key you can use to set proper count - but counting amount of push notification has to be done on server side - iOS doesn't do that automatically.

Checkout the APS reference table 9-1 here

To reset badge count you should use UIApplication method.

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]

Depending on the application logic you need to place that in different locations, but most common usage is to do that on application becoming active.

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]
}

Upvotes: 1

Nilesh Patel
Nilesh Patel

Reputation: 6394

You need to send the updated badgeNumber from your server. Then updated number will be displayed. iOS doesn't do the summation, It just display the number.

Upvotes: 0

Eran
Eran

Reputation: 393876

iOS doesn't sum the badge numbers you send to the app. It just displays the latest badge number sent from your server. You server should send a push notification with badge number of 10 if that's the badge number you want to display.

Upvotes: 7

Related Questions