SetApplicationIconBadgeNumber does not refresh the icon several times when called

I am working on an application in which I have to update the icon shown on the application icon several times. However, I noticed that setApplicationIconBadgeNumber api works once during the whole life of the application. I try to use UILocalNotification, and it works then, but I do not want to follow this route. You guys faced a similar problem. If yes, any pointers?

Relations Nitin

+3
source share
2 answers

This is a bug in iOS. It is still present today in 6.0.1, where I just fixed it:

    // Clear app badge number. Work-around for bug in iOS.
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
+1
source

Perhaps the problem is where you are calling it?

Wrong:

// This is only called once during application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}

:

- (void)applicationWillEnterForeground:(UIApplication *)application {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
0

Source: https://habr.com/ru/post/1765525/


All Articles