UIApplication.shared.applicationIconBadgeNumber = 0 does not reset icon badge number!

Hi everyone,

I am using swift to develop an iOS app. The app receives local notification but after opening the app the badge icon does not reset.
So far I have tried the fallowing codes on AppDelegate

func applicationDidBecomeActive( application: UIApplication) {
UIApplication.shared.applicationIconBadgeNumber = 0
}

func applicationWillEnterForeground(
application: UIApplication) {
UIApplication.shared.applicationIconBadgeNumber = 0
}

I also tried UIApplication.shared.applicationIconBadgeNumber = -1.

None of the above codes reseted the icon badge number. Please help me to solve this problem.

By the way, right now I am using iOS 14 on my iPhone and Xcode 12.0 beta 2, but even for previous version of iOS and Xcode, the code did not reset the badge!


How about doing it in application(_, didFinishLaunchingWithOptions:) in AppDelegate?

SceneDelegate is fired in iOS13 or later, but in this case, i don't think it does not matter.
UIApplication.shared.applicationIconBadgeNumber = 0 does not reset icon badge number!
 
 
Q