David L
David L

Reputation: 569

iOS APNs badge update issue

Say, i have an app with APNs on. the app icon badge number is only up to the badge property of the APNs JSON payload, right ? That means if currently the app icon badge is 1, when a new push notification arrives, the app icon badge will be changed to the badge value of the JSON payload, but not auto increase by 1, if that right ? if so, is there an approach to do that auto increase. or is there a way to get the total notification count for an app in the notification center? Thanks.

Upvotes: 3

Views: 1312

Answers (1)

Moxy
Moxy

Reputation: 4212

With the JSON payload you're actually setting the badge number. The only solution is to manage it server side by notifying the server each time a "notification" is read.

You should add a "read" flag to your objects in the database that are sent as notifications. So for a chat app for example: When you send a notification for a new message, the badge number should be the total of all the conversations with unread flags for that user. And each time the user reads a conversation, you should make an API call to mark it as read in your server and of course decrement the badge number locally.

Upvotes: 3

Related Questions