ApplicationIconBadgeNumber is not getting reset on

2019-08-10 15:09发布

I'm setting my applicationIconBadgeNumber using this code:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:theIntToDisplay];

The problem is that when I delete the app from an iPad and reinstall it, the app icon still shows the previous badge number. Is this default iOS behavior or can we reset it?

I found one similar question on at Why the applicationIconBadgeNumber is not getting deleted with appliccation ? Where it stored actually?, but it didn't answer my question.

2条回答
该账号已被封号
2楼-- · 2019-08-10 15:44

This is an expected behavior, the badge number remains for a short period after uninstall e.g for the case of an immediate re-install.

Of course you can nullify badge number after every launching the application in application:didFinishLaunchingWithOptions: method but I think it is not the case because you want badge number not to be shown right after you install app and not yet launch it. In such a case just wait after removing the application and the badge numbers cache will be cleared by iOS and then install the app again. Unfortunately without jailbreaking the device there is no way to manage badge numbers behavior manually

查看更多
我想做一个坏孩纸
3楼-- · 2019-08-10 15:51

In your app delegate under:

- (void)applicationWillEnterForeground:(UIApplication *)application
{

}

Insert:

application.applicationIconBadgeNumber = 0;
查看更多
登录 后发表回答