I want to clear the push notification badge count once app is launched.Im not clear where to set the below code.Please give brief description about clearing the badge count.
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
Go to Settings and open Notifications. Scroll down and tap on Messages. To disable notifications altogether, toggle off Allow Notifications. To remove badges, turn off the toggle next to Badges.
The iOS badge count displays the number of unread notifications within your application, taking the form of a red circle in the upper-right hand corner of the app icon. In recent years, badging has come to be an effective means for re-engaging app users.
You should set this:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
in either of these AppDelegate methods if the application is launched and sent to background then you launch the application didFinishLaunchingWithOptions
method will not be called so use either of these methods:
- (void)applicationWillEnterForeground:(UIApplication *)application - (void)applicationDidBecomeActive:(UIApplication *)application
For Swift 3+
- func applicationWillEnterForeground(_ application: UIApplication) - func applicationDidBecomeActive(_ application: UIApplication)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With