Domanda

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,

È stato utile?

Soluzione

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.

Altri suggerimenti

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
       //....
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top