Results 1 to 5 of 5
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, ...
  1. #1
    Rookie Array

    Join Date
    May 2008
    Posts
    15
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default Background badging in OS3.0

    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



  2. #2
    Rookie Array

    Join Date
    Nov 2008
    Posts
    14
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    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

  3. #3
    Rookie Array

    Join Date
    May 2008
    Posts
    15
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Quote Originally Posted by xGrill View Post
    You can try using the com.apple.springboard.displaystate.plist file, not sure if you can change any badge numbers that way.
    Thanks for your suggestion.

    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).

  4. #4
    Rookie Array

    Join Date
    May 2008
    Posts
    15
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default 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:

    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;
    }
    Usage: badge(@"com.yourcompany.yourapp",2);

    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)

  5. #5
    Senior Professional Array spektro's Avatar

    Join Date
    Mar 2008
    Posts
    178
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    15

    Default

    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

    Code:
    /* ISSpringBoardUtility header */
    
    @class NSString;
    
    @interface ISSpringBoardUtility
    {
    	NSMutableDictionary *_badgeValues;
    	int _postingBadgeValuesChanged;
    }
    -(void)_updateBadgeValues;
    -(void)_reallySetBadgeString:(id)fp8 forIdentifier:(id)fp16;
    -(void)_loadBadgeValues;
    -(void)_badgeValuesChangedExternally;
    -(void)setBadgeString:(NSString*)str forIdentifier:(NSString*)identifier;
    -(void)cancelDownloadingIconForIdentifier:(NSString*)identifier;
    -(NSString*)badgeStringForIdentifier:(NSString*)identifier;
    -(void)dealloc;
    -(id)init;
    @end
    And just use this:

    Code:
    void badgeIt(NSString *bundleIdentifier, NSString *value)
    {
    	ISSpringBoardUtility *util = [[ISSpringBoardUtility alloc] init];
    	[util setBadgeString:value forIdentifier:bundleIdentifier];
    	[util release];
    }
    Last edited by spektro; 05-16-2010 at 08:57 PM. Reason: 4.0 still has both working !


 

 

Similar Threads

  1. MacNN: Moto Shadow spotted in Verizon's Droid badging
    By hackint0sh in forum Latest Headlines
    Replies: 0
    Last Post: 05-23-2010, 12:20 AM
  2. How to run my app in background?
    By raziiq in forum iPhone Developer Exchange
    Replies: 1
    Last Post: 08-24-2009, 05:56 PM
  3. Background image
    By Pete_London in forum AppleTV 1
    Replies: 0
    Last Post: 02-03-2009, 05:13 PM
  4. Sending SMS on background
    By beit in forum iPhone Developer Exchange
    Replies: 0
    Last Post: 08-12-2008, 02:28 AM
  5. [1.1.2] Changing background?
    By asma123 in forum General
    Replies: 6
    Last Post: 01-04-2008, 06:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 08:35 AM.
twitter, follow us!