我正在使用https://github.com/arnesson/cordova-plugin-firebase/在基于离子的应用上接收Google Firebase消息.
设置证书后,安装插件并设置Firebase帐户我能够通过Firebase控制台接收通知(在Android和ios设备上).
但是,当我通过Firebase API(https://firebase.google.com/docs/cloud-messaging/http-server-ref)发送时,只有Android设备才会收到通知.我正在使用以下代码:
$data = Array
(
[to] => <token>
[notification] => Array
(
[title] => My Title
[text] => Notification test
[sound] => default
[vibrate] => 1
[badge] => 0
)
)
$jsonData = json_encode($data);
$ch = curl_init("https://fcm.googleapis.com/fcm/send");
$header = array(
'Content-Type: application/json',
"Authorization: key=".$gcmApiKey
);
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);
echo $result;
没有错误返回:
{"multicast_id":904572753471539870406,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1477063422322568734%3d5c78243d5c7824"}]}
有什么不对?
最佳答案:
对于iOS,请尝试在您的有效负载中将参数优先级设置为high并将content_available设置为true.
请参阅参数详细信息here.
原文地址:https://codeday.me/bug/20190516/1114782.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。