Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: How to set the application badge, when the app is closed/in background?

is it possible to set the application badge, while the app is in background mode or even closed? I haven't found anything, yet.

Application Badge

like image 938
Stefan Avatar asked May 11 '11 08:05

Stefan


2 Answers

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.

like image 105
visakh7 Avatar answered Oct 26 '22 21:10

visakh7


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.

like image 37
Luke Avatar answered Oct 26 '22 23:10

Luke