views:

584

answers:

3

Anybody know how to implement the red number indicators (like the email count notification)? I cant seem to google this up anywhere.

Thanks!

A: 

What you want is called a "badge".

[UIApplication sharedApplication].applicationIconBadgeNumber = 2;

EDIT: removed SetApplicationBadge

Chris McCall
I'm still unsure where you are getting this `setApplicationBadge` method from.
Luke Redpath
Yeah, me either. Removed it.
Chris McCall
+7  A: 

What you are looking for is the applicationIconBadgeNumber property which is a property of UIApplication.

To set the badge, from anywhere in your app, use:

UIApplication *application = [UIApplication sharedApplication];
application.applicationIconBadgeNumber = 1; // set to any integer

To remove the badge, set the property to 0.

Documentation on Apple Developer Website

Luke Redpath
thanks! i suppose default iphone apps, such as email, can set these badge counts even when the app isnt running (or the app runs silently in the background). because they get badge updates even when they're not open.
Edward An
Yes, but you can use the push notification service to push badge updates over the air. Without the PNS, you need to update the application badge when your application launches.
Luke Redpath
BTW, if this answers your question, please don't forget to mark it as an answer.
Luke Redpath
A: 

It looks like a code you guys are using involves a program. (I assume) What program are you guys using? And where do you get it? Thanks in advance.

Silent-type