ios 当应用程序未打开时收到推送通知时更新徽章编号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16164339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Update Badge Number when push notification is received when App is not Open
提问by user2174560
I have an App in which i am facing the issue that the badge number only gets updated when i open the notification but i need to update the badge number even when app is not open.
我有一个应用程序,其中我面临的问题是徽章编号仅在我打开通知时更新,但即使应用程序未打开,我也需要更新徽章编号。
Can anyone help me with that??
有人可以帮我吗??
回答by Mike Weller
You need to set a value for the badge
key in your push notification payload. From your description, it sounds like it is only your application which is updating the badge number, and not the notification itself.
您需要为badge
推送通知负载中的键设置一个值。从您的描述来看,似乎只有您的应用程序在更新徽章编号,而不是通知本身。
See The Notification Payloadof the Local and Push Notification Programming Guide for details:
详情参见本地和推送通知编程指南的通知负载:
Keys and values of the aps dictionary
badge
(number): The number to display as the badge of the application icon. If this property is absent, the badge is not changed. To remove the badge, set the value of this property to 0.
aps 字典的键和值
badge
(number):显示为应用程序图标徽章的数字。如果此属性不存在,则不会更改徽章。要移除徽章,请将此属性的值设置为 0。