Apple 推送通知徽章编号 [英] Apple push notification badge number

查看:81
本文介绍了Apple 推送通知徽章编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了服务器端应用程序,以在收到新通知后将徽章编号保持为递增或递减,并在看到通知后删除它工作正常.

I have developed server side application to maintain the badge number as increment or decrement after receiving new notification and delete after seeing notification it works fine.

但是在显示徽章时存在一些问题,实际情况是 - 在设备上收到新通知后,我点击取消按钮然后徽章号码显示正确,但之后我将打开应用程序并关闭应用程序徽章被移除.这意味着我不会向服务器发送我看到通知的请求,现在您可以将徽章减一.然后也从应用程序图标中删除了徽章.

But there is some problem in showing the badge, the actual scenario is - After getting new notification on device, I am click on cancel button then badge number shows correctly but after that I will open the application and close the application badge will be removed. That means I am not sending request to the server that notification was seen by me and now you can decrement the badge by one. Then also badge removed from app icon.

我的问题是,当我们打开应用程序时,徽章编号会自动从(应用程序)设备中删除?或者它会一直显示直到我们设置为零?

My question is that when we open the application then badge number automatically removed from (application) device? or it will shows as it is until we set to zero?

推荐答案

它会一直显示,直到您将其设置为零为止,您可以使用以下代码进行操作:

It will show until you set it to zero and you can do it with the following code:

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]



在收到通知时设置徽章编号更为常见,在 application:didReceiveRemoteNotification:application:didFinishLaunchingWithOptions: 方法中 UIApplicationDelegate> 班级.



It is more common to set the badge number as you receive the notification, in either application:didReceiveRemoteNotification: or application:didFinishLaunchingWithOptions: methods of your UIApplicationDelegate class.

您可以在本地和推送通知中阅读更多相关信息编程指南

这篇关于Apple 推送通知徽章编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆