I use [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]
to clear badge number. It works fine but remote notifications are removed at the same time.
There are many other questions to clear notification center but I would NOT like to clear them. I just want to clear number of badge while preserving notifications.
Is there any way to achieve this?
One hacky way around this is to set the badge count to a negative value. Negative values aren't shown on the home screen and since they're non-zero, they don't cause the notification center to get cleared.
Try [[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1]
and see if it results in the user facing behavior that you want.
As far as I know, it is impossible to set badge value to 0. The application badge value will be shown only when it is more than 0. Otherwise, (in case of 0), it will be just hidden by ios.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1]
it is not working for me .
but i try this is okay.
UILocalNotification *notification=[[UILocalNotification alloc]init];
notification.applicationIconBadgeNumber=-1;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];