rch850 rch850 - 1 year ago 69
iOS Question

How to clear badge number while preserving notification center

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?

Answer Source

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.