Question

I'm using PushBot as my push notification service, my issue is how do I reset the badge count. I've search and read to use this line of code:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

The only way the badge count gets reset is if I quit the app from running on the mulit-task bar and launch the app again, any help is greatly appreciated. Thanks,

Was it helpful?

Solution

Just make a button on your UI and on his action put the code line:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

It will reset it.

Take a look Here for some other implementations.

OTHER TIPS

To clear the badge count whenever the application becomes active, simply include your line of code:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

In the AppDelegate.m file's applicationDidBecomeActive delegate method.

applicationDidFinishLaunchingWithOptions is only called on the initial launch, and does not get called again when the application goes to the background and back to the foreground.

For Swift 3.0

//AppleDelgate.swift
 func applicationDidBecomeActive(_ application: UIApplication) {
        //....
        application.applicationIconBadgeNumber = 0
       //....
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top