am working on push notifications app but badge count is not increasing when notification comes.
i have saw so many examples in stack overflow
You have to manage your server side when you send a notification to other user then from php side they set a counter to increment the badge & send the notification to other user after that when you open your app the badge is set to null like this :
- (void) applicationWillResignActive:(UIApplication *) application
{
application.applicationIconBadgeNumber = 0;
}
& to receive the notification you set this code :
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"userInfo %@",userInfo);
for (id key in userInfo)
{
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
[application setApplicationIconBadgeNumber:[[[userInfo objectForKey:@"aps"] objectForKey:@"badge"] intValue]];
NSLog(@"Badge %d",[[[userInfo objectForKey:@"aps"] objectForKey:@"badge"] intValue]);
NSString *message = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}