I want to change badge of my application when my application is in inactive state. When my application is in active state The badge is incrementing by 1 by
-(void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo
{
NSInteger badgeNumber = [application applicationIconBadgeNumber];
[application setApplicationIconBadgeNumber:++badgeNumber];
NSInteger badgeNumber = [application applicationIconBadgeNumber];
[application setApplicationIconBadgeNumber:++badgeNumber];
}
But when my application is in the inactive state. I read that the operating system automatically give the badge send in the payload. Here is my payload:
{
"aps": {
"alert": "You have an image to view",
"sound": "default",
"badge": 2
}
}
But the badge is not changing. Can any one help me with this.