[[UIApplication sharedApplication] setApplicationIconBadgeNumber:10];
You can use this line anywhere in the project to set the badge number. Another proper way to set the badge number is when terminating the application. So here is the sample code for that.
/// In application delegate
- (void)applicationWillTerminate:(UIApplication *)application
{
int badgeNumber = [self countBadgeNumber]; // Method to find badge number
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeNumber];
}
Note: If the badge number is 0, no badge will be displayed.
No comments:
Post a Comment