Fork me on GitHub
Home

Reset App Icon Badge with UILocalNotification

30 April 2011

For our new super secret project at furryfishApps, we are heavily using UILocalNotification and the badge on our App’s icon.

Just to quickly revisit: when a UILocalNotification is fired, it’ll set the badge to the number, that you previously defined like this:

UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.applicationIconBadgeNumber = 3;
// TODO schedule notification
gist

While trying to remove the badge, I found that there is no documentation on this whatsoever. You might think it should be easy, just set the property applicationIconBadgeNumber to 0, however here’s what UILocalNotification’s documentation says:

The default value is 0, which means “no change.” The application should use this property’s value to increment the current icon badge number, if any.

Well, that means the badge is not removed when setting the property applicationIconBadgeNumber to 0, instead you need to set it -1. As soon as the UILocalNotification is fired, the badge is removed from the App’s icon.

Would be nice to have that in the documentation, so I filed radar://9357622.


// other posts