I am using Parse iOS SDK. I have problem in resetting the badge count. I am using the tutorial(parse) code to send push notifications. I am using increment for badge, but the badge count keeps on incrementing. I am resetting the badge count in applicationDidBecomeActive: method like this,
- (void)applicationDidBecomeActive:(UIApplication *)application {
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if (currentInstallation.badge != 0) {
currentInstallation.badge = 0;
[currentInstallation saveEventually];
}
// ...
}
It just resets the badge number locally. But when I send the push notification next time, it just increments the previous count value and displays it. I guess the badge number in Parse server is not getting reset. Also, I tried to use [currentInstallation saveInBackground];
, but it not working too. Help
Try leaving away the if-statement (if you don't mind unnecessary api requests):
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.badge = 0;
[currentInstallation saveEventually];
It seems that sometimes the installation.badge != 0
check fails.
This is how I solved my desynced badges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With