当应用程序未打开时收到推送通知时更新徽章编号

当应用程序未打开时收到推送通知时更新徽章编号

问题描述:

我有一个应用程序,其中我面临的问题是徽章编号仅在我打开通知时更新,但即使应用程序未打开,我也需要更新徽章编号.

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.

有人可以帮我吗??

您需要为推送通知负载中的 badge 键设置一个值.从您的描述来看,似乎只有您的应用程序在更新徽章编号,而不是通知本身.

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.

参见 Notification Payload 本地和推送通知编程指南详情:

See The Notification Payload of the Local and Push Notification Programming Guide for details:

aps 字典的键和值

badge(编号):显示为应用程序图标徽章的编号.如果此属性不存在,则不会更改徽章.要移除徽章,请将此属性的值设置为 0.

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.