13

I am working with push notifications. When I get a notification it comes with 2 button, view and close. If I click on view it opens the app and when I click the close button it does nothing but a badge number appears on the app icon. Then when I open my app again that badge number should disappear but it doesn't. How can I remove that badge number if user clicks on app icon? Thanx

4

2 回答 2

40

将以下代码放在 applicationDidFinishLaunching 或 applicationDidBecomeActive 中的某处。

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
于 2011-02-28T17:34:02.613 回答
1

您可以做的是badge从远程通知中省略密钥,以便删除当前显示的任何徽章编号。如果您希望在用户点击查看时显示徽章,您可以使用 设置徽章编号[UIApplication sharedApplication].applicationIconBadgeNumber

但我不确定你为什么要这样做。

于 2011-02-28T17:45:36.107 回答