Question

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;
}
Was it helpful?

Solution

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 .

OTHER TIPS

Set it to -1 like this:

application.applicationIconBadgeNumber = -1;

or like this:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top