iPhone: How to set the application badge, when the app is closed/in background?
11,478
Solution 1
From within your application you can use the applicationIconBadgeNumber
property of UIApplication
to set the badge number:
[UIApplication sharedApplication].applicationIconBadgeNumber = 1;
If you want to change the badge without the user launching your app, you need to use the push notification service. The Push Notification Service Programming Guide should have all the info you need.
Solution 2
It is possible via push notifications (as you've tagged) but bare in mind that if the user has disallowed push notifications it won't work.
To update the badge number via push, you need to include the following in your payload:
"badge" : 23
For more info about the payload, see this apple doc.
Author by
Stefan
Updated on June 05, 2022Comments
-
Stefan almost 2 years
is it possible to set the application badge, while the app is in background mode or even closed? I haven't found anything, yet.
-
5hrp almost 13 yearsadd to your answer (if you think it proper addon), that @Stefan also can use Local Notifications
-
Stefan almost 13 yearsOk, that is what I hoped :-) At least there is a way to set the badge without having the app running.