Chris Alvares
Porfolio About Me Contact Me Social Blog

Archive

Posts Tagged ‘Springboard Icons’

iPhone tip: Springboard Badge numbers in 3.0

July 13th, 2009

Wouldn’t it be cool if you could your next iPhone app could see if the user had mail, had a new AIM message, or even a new cal appointment? Well now you can, the following objective-c code will tell you the badge number of any application on the users springboard.

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Caches/com.apple.springboard.displaystate.plist"];
if(dict == nil)
	return NSLog(@"not able to read displaystate");
NSDictionary *appDict = (NSDictionary *)[dict valueForKey:@"com.chrisalvares.CALocationService"];
if(appDict == nil)
	return NSLog(@"application was not found");
 
NSNumber *badgeNumber = [appDict objectForKey:@"SBApplicationBadgeKey"];
if(badgeNumber == nil)
	return NSLog(@"BadgeNumber was not found");

Update: If you want to edit the badge numbers in iPhone 3.0 look here.

admin Uncategorized , , , , , ,