|
|||||||||
|
|||||||||
|
|||
|
Hi all,
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... Thanks
|
|
|||
|
You can try using the com.apple.springboard.displaystate.plist file, not sure if you can change any badge numbers that way.
See Chris Alvares blog iPhone tip: Springboard Badge numbers in 3.0 |
|
|||
|
Quote:
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). |
| Sponsored links Remove advertisements | |
|
|
|
|
|
|||
|
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: ISOperation.h ISOperationProgress.h ISSetApplicationBadgeOperation.h 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: Code:
BOOL badge(NSString *bundleIdentifier, NSInteger number)
{
ISSetApplicationBadgeOperation *sbadge = [[ISSetApplicationBadgeOperation alloc] init];
if (sbadge == nil) return FALSE;
[sbadge setBundleIdentifier:bundleIdentifier];
[sbadge setBadgeValue:[NSString stringWithFormat:@"%d",number]];
[sbadge run];
[sbadge release];
return TRUE;
}
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) |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a background iPhone application that is always running | UndeadCretin | iPhone Developer Exchange | 0 | 04-02-2009 12:49 PM |
| AppleInsider: Apple rumored allowing real background apps on iPhone | hackint0sh | Latest Headlines | 0 | 02-04-2009 02:10 AM |
| MacNN: Background processes to show in iPhone 3.0? | hackint0sh | Latest Headlines | 0 | 02-03-2009 11:00 PM |
| [UIWebView] Transparent background ? | attodorov | iPhone Developer Exchange | 0 | 05-06-2008 04:37 PM |
| iPhone Main Background | maccabbi | General | 2 | 07-16-2007 06:21 PM |
|
|