Discuss Background badging in OS3.0 at the iPhone Developer Exchange - Hackint0sh.org; Hi all,
The method used to badge applications from the command line (Erica Sadun style, ...
Background badging in OS3.0
The method used to badge applications from the command line (Erica Sadun style, with Dynamic Linking to the SBSSpringBoardServerPort) is no longer valid in 3.0. I'm guessing Apple changed it when adding the push-notification service.
Trying to badge an app just ends up with a "Bus Error".
And I can't use the UIApplication +setApplicationIconBadgeNumber: since it's a daemon doing the badging.
Any geniuses out there who have an idea as to what I can try? I'm out of ideas...
You can try using the com.apple.springboard.displaystate.plist file, not sure if you can change any badge numbers that way.
Chris Alvares blog iPhone tip: Springboard Badge numbers in 3.0
Thanks for your suggestion.
Originally Posted by xGrill
I fiddled around with that, but changing the value doesn't affect the springboard. So I figured that I might have to post a notification, to make it refresh the values from the file .. but I've been going through all the notifications and nothing does the job.
What I did find out though, was that the contents of the file is reset to the original "un-hacked" values when I receive a mail for example.. so my guess is, that the badge must be posted to an in-memory process that then updates the springboard (and the displaystate file).
Background badging in OS3.0 [SOLVED]
OK.. I solved it.
Here's what you do:
Use class-dump to dump the headers for /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/iTunesStore.framework/iTunesStore
..OR go to iPhone 3.0 Headers at Erica Sadun's site to get the following 3 class headers:
You may have to edit ISOperation.h:
1. Change the #import "NSOperation.h" to #import <Foundation/NSOperation.h>
2. Remove the "<ISOperationDelegate>" in the first part of the interface. So you're just left with "id _delegate;"
Then copy these 3 files into a "Headers" dir inside of the /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/iTunesStore.framework dir.
You can now add the iTunesStore framework to your xcode project. Just point to the dir above.
Now add "#import <iTunesStore/ISSetApplicationBadgeOperation.h>" to your code and, for your convenience, here's an example-function ready for use:
BOOL badge(NSString *bundleIdentifier, NSInteger number)
ISSetApplicationBadgeOperation *sbadge = [[ISSetApplicationBadgeOperation alloc] init];
if (sbadge == nil) return FALSE;
[sbadge setBadgeValue:[NSString stringWithFormat:@"%d",number]];
Remove the badge by passing 0 as the number. Sadly it doesn't work with strings..
Do note, that we're using undocumented methods here, so they could change at any point ..which Apple isn't shy to tell us. Let's hope they keep it around for a while.
Cheers and happy coding
(Thanks to Steve Nygard for class-dump and Erica Sadun for being such a great source for information. Aaah, free information)
This one produce the same effect as yours. Even using the _reallySetBadgeString:forIdentifier: no dice for strings, only numbers
Seems the real implementation gets the intValue of it and puts there as a badge.
The funny thing happens when you put something greater that 999. For 1000, it puts 1.000 as the badge value.
Oh, and it's important to say both still work in 4.0
And just use this:
/* ISSpringBoardUtility header */
void badgeIt(NSString *bundleIdentifier, NSString *value)
ISSpringBoardUtility *util = [[ISSpringBoardUtility alloc] init];
[util setBadgeString:value forIdentifier:bundleIdentifier];
Last edited by spektro; 05-16-2010 at 08:57 PM.
Reason: 4.0 still has both working !
By hackint0sh in forum Latest Headlines
Last Post: 05-23-2010, 12:20 AM
By raziiq in forum iPhone Developer Exchange
Last Post: 08-24-2009, 05:56 PM
By Pete_London in forum AppleTV 1
Last Post: 02-03-2009, 06:13 PM
By beit in forum iPhone Developer Exchange
Last Post: 08-12-2008, 02:28 AM
By asma123 in forum General
Last Post: 01-04-2008, 07:26 PM