Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: how to remove badge after Push Notification?

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!

like image 465
obliviux Avatar asked Nov 26 '09 12:11

obliviux


People also ask

How do I get rid of the notification badge on my iPhone?

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.

How do I delete icon 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.


2 Answers

objC :

[UIApplication sharedApplication].applicationIconBadgeNumber = 0; 

swift :

UIApplication.sharedApplication().applicationIconBadgeNumber = 0; 
like image 107
Felixyz Avatar answered Sep 22 '22 03:09

Felixyz


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; } 
like image 36
Ravindra Naik Avatar answered Sep 22 '22 03:09

Ravindra Naik