Frage

I'm not sure what I changed in my app, but Im not able to clear the badges number anymore.

I put code the following code:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

in:

 - (BOOL)application:(UIApplication *)application
           didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

I also tried:

application.applicationIconBadgeNumber = 0;

It just wont work, even though it did before, please advice

full code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

    //Let the device know we want to receive push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];

    NSLog(@"didFinishLaunchingWithOptions");

    //application.applicationIconBadgeNumber = 0;
    //[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

    return YES;
}
War es hilfreich?

Lösung

You're calling it in didFinishLaunchingWithOptions that way it'll only get cleared on launching the app.

Have you tried killing the app from the multitasking menu and launching it again?

Also try and move setApplicationIconBadgeNumber in applicationDidBecomeActive .

Andere Tipps

Set it to -1 like this:

application.applicationIconBadgeNumber = -1;

or like this:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top