Guyz help me please to understand badge count management. I’ve read that apple guide but did not exactly understand who is responsible of management that count on icon?
if my app is not foreground i’m getting an alert(and “1” on icon) and if I tap View my app is launching and I decrease badgeCount:
[UIApplication sharedApplication].applicationIconBadgeNumber = [UIApplication sharedApplication].applicationIconBadgeNumber - 1;
That’s ok for a single notif. But where should I increase my badge count? For example if I receive 2 or 3 notifications I’m still having “1” on the app icon..or should iOS increase that count itself?
EDIT:
I’ve already found that server should send the proper number for example:
{
"aps" : {
"badge" : 9
}
}
but how server knows the right number if for example I’ve already “read” a couple of news and current number not “9” but “7”? I need to pass that information to server?
Please explain me how this works! Thanks in advance!
When your app is in background(suspended) or not running at all then iOS is handling badge on app icon and it’s set to the number found in notification payload. iOS doesn’t do any counting of notifications.
When app is running then its responsible for badge updating. In your case I think it should work like Mail app so app should tell server that user has read some stuff so server knows how many news have not been read yet so server can then send proper badge number once app is in background again and there is new news.
Scheduling, Registering, and Handling Notifications