When app is in foreground, even if I set the applicationBadgeNumber to 0, when I quit the app, there’s still a “1” badge on my app, even whem I kill it, any ideas? When I open the notification when the app is in background, no problem at all!
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"%i", notification.applicationIconBadgeNumber); // Return 1
notification.applicationIconBadgeNumber = 0;
NSLog(@"%i", notification.applicationIconBadgeNumber); // Return 0
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateInactive)
{
// Application was in the background when notification
// was delivered.
}
else
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"An item is asking your attention" message:nil delegate:nil
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Show me", nil];
[alert show];
}
}
Where are you setting the applicationBadgeNumber? I think you are setting the notification badge number.
Try this: