Several native applications on the iPhone use application badges as an indicator of new messages, think email and SMS. Creating badges is quite straightforward and is nothing more than a method call, passing in the desired number to display.
The image below shows how a badge may look when applied to your application. The code to create the badge is below the image.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:99];
As one would expect, the iPhone does limit the number of digits it will display – see the code and image that follow:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:123456];
One nice feature that would be welcome is to have a means to create a badge with text. I’ve seen a number of references to using an undocumented method (see below), however, I was unable to get the code to work.
[[UIApplication sharedApplication] setApplicationBadge:@"Beer"];
Although you can set a badge for an application icon, I believe the real creative uses of this will evolve if/when Apple provides a means for an application to update the badge when the application is not running. For example, I am working on an application that needs to notify users that they are x number of days away from an upcoming event. It would be a nice feature of the application if one could glance at the icon and see the current count, versus having to start the application.
I’ll keep my fingers crossed…