I want to set an icon badge while I am not in the application, like the Mail application. How can I do that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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.
回答2:
The iPhone SDK doesn't support that functionality yet. It can only be done on a jailbroken device.
EDIT: Sorry that's not ENTIRELY true, you can do it with the 'push' function but only apps that are screened by Apple are allowed at this stage.
EDIT AGAIN: Nope I'm completely wrong try this
[UIApplication sharedApplication].applicationIconBadgeNumber = 2;