Reputation: 37581
I'm queueing local notifications and setting the badge count to 1.
If I queue a few then exit the app then when they trigger each one of them sets the badge count to 1, rather than incrementing it. i.e. suppose I queue 3 then after all of them fire the badge count on the app will show as 1.
Is there a way that the badge count can increment by one when each fires?
Examining applicationIconBadgeNumber when the notification is set is not an option - because consider a scenario like this:
App schedules notification A for 1 minutes, current badge count is 0, so notification.count = 1
App schedules notification B for 10 minutes, last badge count is 1, so notification.count = 2
App schedules notification C for 5 minutes, last badge count is 2, so notification.count = 3
But notification C fires before B, so when it fires the badge count would be set to 3 which is incorrect, then when B fires the count goes to 2 which is also incorrect.
If there's no automatic way of incrementing the count then the app would have to implement a complicated scheme where it remembers everything its queued and the time of each. Is there a simple way?
Upvotes: 0
Views: 951
Reputation: 203
int num = [[UIApplication sharedApplication]applicationIconBadgeNumber];
if (num == 0) {
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:1];
}
else if (num >= 1) {
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:num + 1];
}
I think this will solve it.
Upvotes: 1