What is the code to remove the badge on my app's icon? When I receive push, I need to remove it when a button is clicked!
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.
You can easily clear notification badges on app icons at the same time by dismissing the corresponding notifications. So if you swipe notifications on notification panel, or tap CLEAR. Badges with numbers are disappeared at that time.
objC :
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
swift :
UIApplication.sharedApplication().applicationIconBadgeNumber = 0;
You can remove badge from push notifications by adding the following lines to your code
(void)applicationDidBecomeActive:(UIApplication *)application { [[UIApplication sharedApplication] cancelAllLocalNotifications]; [UIApplication sharedApplication].applicationIconBadgeNumber = 0; }
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