这是为其他遇到同样问题的人准备的。
我相信您正在谈论使用从服务器收到的更新徽章编号使徽章可见。
首先要在 Push 的 init 方法的代码中启用它,如下所示
var push = PushNotification.init({
android: {
senderID: senderID,
icon: 'pushicon',
sound: "true",
iconColor: "#ED8B00"
},
browser: {
pushServiceURL: 'url'
},
ios: {
alert: "true",
**badge: "true",**
sound: "true"
},
windows: {}
});
在上面的代码中,我们启用了徽章{将在所有 iPhone 和支持的 Android 手机中显示}
现在从服务器端。
将以下部分添加到您的 ios 部分,这样即使您的应用程序处于后台,也会获得更新计数。
仅适用于ios,请根据您的要求添加Android;
{
"aps": {
"alert": {
"title": "Received",
"body": "You have received a message from Kens"
},
"badge": 66
},
"received_id": "9223",
"pn_type": "RECEIVED"
}
即使应用程序处于后台,此徽章计数也会自动更新为应用程序徽章计数。(但徽章字段应为整数)。
谢谢希望这有助于并解决您的问题。