I am using this code. Every thing works fine when a push notification appears, but the icon number does not increase when the application is in the background. How to solve this problem?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
NSInteger badgeNumber = [application applicationIconBadgeNumber];
[application setApplicationIconBadgeNumber:[[[launchOptions valueForKey:@"aps"]valueForKey:@"badge"]integerValue]];
NSLog(@"userInfo :%@ %d",launchOptions,[[[launchOptions valueForKey:@"aps"]valueForKey:@"badge"]integerValue]);
return YES;
}
source
share