Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing badge from iOS app icon

Tags:

ios

iphone

badge

In this application that I'm trying to make, I use push notifications. This part works just fine. When I send a notification I also add a badge to the app icon. The problem is when I lunch the application it should disappear again, but it does not.

-(IBAction)Push{      NSMutableDictionary *data = [NSMutableDictionary dictionary];      [data setObject:@"Numfeud: Troels made a move!" forKey:@"alert"];      [data setObject:[NSNumber numberWithInt:1] forKey:@"badge"];      [data setObject:@"bar" forKey:@"foo"];      [PFPush sendPushDataToChannelInBackground:@"GameChannel2" withData:data]; } 

In the application didFinishLaunchingWithOptions I try to set badge to 0 in this way:

[UIApplication sharedApplication].applicationIconBadgeNumber = 0; 

How can I clear the application icon badge?

like image 641
thar Avatar asked Mar 04 '12 17:03

thar


People also ask

How do I delete badges on my iPhone apps?

Tap the Focus button. Tap the ellipsis (three dots) button next to a Focus mode, then select Settings in the dropdown. Under "Customization," tap Options. Tap the switch next to Hide Notification Badges to enable the option.

How do I get rid of red numbers on apps?

On your device, navigate to Settings -> Application Manager -> All -> BadgeProvider. Within these preferences, select Force Stop, then Disable. Restart your device and you'll notice that any pre-existing app icon badges are now gone, and no new ones will show up.


1 Answers

If your app becomes active again and is still in the background you should reset the badge count in -applicationDidBecomeActive: as well:

- (void)applicationDidBecomeActive:(UIApplication *)application {     application.applicationIconBadgeNumber = 0; } 

If your app is still running in the background -application:didFinishLaunchingWithOptions: won't be called.

like image 112
Mark Avatar answered Sep 22 '22 01:09

Mark