I have seen the mail app in my iPhone (4S, iOS 5.1) automatically updates the badge count if new mail arrives, even when app is not running. So it is possible to achieve this behavior in my app also, right?
My application successfully registers for push notifications for all 3 types - Badge, Alert and Sound. Phone Settings is set ON for all 3 types of remote notifications for this application.
My app receives remote notifications and shows alert, plays sound, but it does not update the badge number. If I launch the app via the View button on the alert, then my app can read the badge value perfectly and I can change/remove/set the icon badge from code.
Any specific reason why iOS cannot change the icon badge of my app automatically when the notification arrives? I have seen all the similar posts, they are all discussing about either phone settings, or about notification types that it registered, or about checking the payload JSON includes badge or not.
Is there any other reason that might cause this problem?
Here is my code blocks:
Register for APNs every time app is launched -
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
Device token received almost instantly. Token has been sent to provider, and I am receiving notifications. Alerts and Sounds works. But badge has no automatic effect until I launch the app and change it manually. Please help.
If the badges are not displaying, you'll need to enable the notifications for that app and then turn on the app icon badges. Icon badges are only natively supported by the One UI Home launcher. If you are using an alternative launcher, badges may not be supported.
Go to Settings and open Notifications. Scroll down and tap on Messages. To disable notifications altogether, toggle off Allow Notifications. To remove badges, turn off the toggle next to Badges.
Open Settings again and see if the option to enable Badges appears. Restarting your iPhone often fixes issues like this.
The system makes every attempt to deliver local and remote notifications in a timely manner, but delivery isn't guaranteed. The PushKit framework offers a more timely delivery mechanism for specific types of notifications, such as those VoIP and watchOS complications use.
I also had this exact same problem. The badge icon was not quoted. After many hours of trying to tweak the JSON (after verifying app on phone showed badges, sounds, alerts) - the problem was I had added UIRemoteNotificationTypeNewsstandContentAvailability as one of the alert types my app was registering for. (I went crazy, just picking everything)
So, when UIRemoteNotificationTypeNewsstandContentAvailability
is also in the mix, it seems to override the function of allowing aps/badge numbers to update an app icon. (Must be looking to update newsstand info)
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