0
我对Google FCM很困惑。 文档页面https://firebase.google.com/docs/cloud-messaging/http-server-ref列出了API支持的参数,但奇怪的是,“badge”参数仅显示为“iOS”。谷歌FCM:徽章柜台限于iOS?
我正在设置我的android应用程序徽章计数器,直到上周成功,但今天,在“通知”部分发送参数“徽章”不起作用。通知成功到达。
我通知数据结构:
Array
(
[to] => (device token)
[notification] => Array
(
[title] => Title
[text] => Test message
[sound] => default
[vibrate] => 1
[badge] => 2
)
)
我的服务器端代码(PHP):
$jsonData = json_encode($data);
$ch = curl_init("https://fcm.googleapis.com/fcm/send");
$header = array(
'Content-Type: application/json',
"Authorization: key=".MY_GCM_API_KEY
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$result = curl_exec($ch);
curl_close($ch);
嗯...这个答案现在仍然有效吗? – Ionut
是的。在O android中引入了徽章,但它们是由系统自动处理的,无法控制。 –