收到推送通知时清除徽章
当我收到推送通知时,如何清除应用程序图标上出现的徽章?我想在用户点击推送通知警报的“查看”或点击应用程序图标后清除它。
How can I clear the badge which appears on application icon when I receive Push Notification? I want to clear it once user has either tapped on "View" of Push notification alert or has tapped on the app icon.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我怀疑你在谈论 SpringBoard 的徽章:
I suspect you are talking about the SpringBoard's badge:
Badge count set Zero
使用此代码取消所有本地通知:
使用此行代码取消一个本地通知:
这里 theNotification 是一个 UILocalNotification 对象,因此为了取消特定通知,您需要保留它的 UILocalNotification。
检查此。
Badge count set Zero
Cancel all local notifications with this code:
Cancel one local notification with this line of code:
here theNotification is a UILocalNotification object, so in order to cancel a specific notification, you need to hold on to it's UILocalNotification.
Check this.
对于 Mac OS X Lion,它是:
(Lion 支持徽章类型推送通知。)
For Mac OS X Lion, it's:
(Lion supports badge-type push notifications.)
根据 Apple 文档,将
application.applicationIconBadgeNumber
设置为您想要在徽章上显示的数字。如果设置为0,则会被清除。参考 - 向下滚动到处理清单 2.4 上方的本地和远程通知部分
From Apple's documentation, set the
application.applicationIconBadgeNumber
to the number you want displayed on the badge. If you set it to 0, it will be cleared.Reference - Scroll down to the Handling Local and Remote Notifications section just above listing 2.4