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?
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.
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.
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.
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