Problem:
- Let say I get 3 notification.
- It shows the badge count 3 on my app icon.
- I open the app or click on the notification and it clears the badge (All Good so far)
- Now when I get a new notification, the badge count shown on my app icon is 4 instead of 1
- That means that the badge count was not reset on Urbanairship end
My Code so far:
-(void)resetBadgeNotifications:(UIApplication *)application using:(NSDictionary *)notificationInfo{
if( notificationInfo != nil ){
[[NSNotificationCenter defaultCenter] postNotificationName:@"newNotification" object:notificationInfo];
}
application.applicationIconBadgeNumber=1;
application.applicationIconBadgeNumber=0;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[application cancelAllLocalNotifications];
[[UAPush shared] setBadgeNumber:1];//set to 1
[[UAPush shared] resetBadge];//zero badge
}
I am calling this method from the following three places:
didFinishLaunchingWithOptions
didRegisterForRemoteNotificationsWithDeviceToken
applicationDidBecomeActive
In the last line of my function, I am clearly resetting the badge on UrbanAirship. But it seems to be not working. Can anyone please correct me if I am missing something?