My app badge count in not increasing when app is in background for push notifications.Count increase by 1 only for the first push notification and always remains badge count as 1, if i get more then 1 notification also badge count remaing 1 only. Below is my code
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSString *message = nil;
id alert = [userInfo objectForKey:@"aps"];
if ([alert isKindOfClass:[NSString class]]) {
message = alert;
}
else if ([alert isKindOfClass:[NSDictionary class]]) {
message = [alert objectForKey:@"alert"];
}
if (alert) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"xyz"
message:message
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
alertView.tag=2525;
[alertView show];
}
}
-(void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
if(alertView.tag==2525) {
[UIApplication sharedApplication].applicationIconBadgeNumber =
[UIApplication sharedApplication].applicationIconBadgeNumber-1;
}
}