如果我点击推送通知中的关闭按钮,如何删除徽章编号?
我正在处理推送通知。当我收到通知时,它有两个按钮:查看和关闭。如果我单击“视图”,它会打开应用程序,而当我单击“关闭”按钮时,它不会执行任何操作,只是应用程序图标上会出现一个徽章编号。然后,当我再次打开我的应用程序时,徽章编号应该消失,但事实并非如此。如果用户单击应用程序图标,如何删除该徽章编号?谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将以下代码放入 applicationDidFinishLaunching 或 applicationDidBecomeActive 中的某个位置。
put the following code somewhere in your applicationDidFinishLaunching or applicationDidBecomeActive.
您可以做的就是从远程通知中省略
badge
键,以便 当前显示的任何徽章编号均已删除。如果您希望在用户点击“查看”时显示徽章,则可以使用[UIApplication sharedApplication].applicationIconBadgeNumber
设置徽章编号。但我不确定你为什么要这样做。
What you could do is omit the
badge
key from your remote notification so that any badge number currently shown is removed. If you want a badge to show up if the user taps View, you can set a badge number using[UIApplication sharedApplication].applicationIconBadgeNumber
.But I'm not sure why you'd want to do this.