android - FCM android - 发件人ID不匹配
问题描述
我有一个使用 FCM 为多个设备发送推送通知的应用程序。
当我发送通知时,我收到错误:
{"multicast_id":7972874062893873258,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
我已经尝试使用服务器密钥和旧服务器密钥,但得到了同样的错误。
使用 googleservice.json 并在集成 json 后卸载应用程序。
我进行了很多研究,并确保我添加了 FCM 需要的所有先决条件。
有什么建议么?
function sendPushNotificationToFCMSever($token,$title, $desc, $API_SERVER_KEY) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'registration_ids' => $token,
'notification' => array (
"body" => $title,
"title" => "Title",
"icon" => "myicon"
)
);
$fields = json_encode ( $fields );
$headers = array (
'Authorization: key=' . $API_SERVER_KEY,
'Content-Type: application/json'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );
$result = curl_exec ( $ch );
curl_close ( $ch );
return $result;
}
解决方案
推荐阅读
- python - 未来如何使用训练有素的模型
- python - 以 JSON 文件格式读取 ASN 数据
- php - Gmail 缓存搞砸了像素跟踪
- databricks - Databricks - CSV 未正确加载
- java - 在 Guice 中初始化 Java 实例时出现异常
- split - 如何获取由特定字符分隔的字符串的一部分?
- wso2-am - 登录 WSO2 API Manager 2.0.0 Carbon 控制台后显示“403 禁止”
- javascript - Javascript 功能在主页上运行,但在第二页上停止
- javascript - 如何测试不导出任何内容的常规 JavaScript 代码?
- python - swaplevel() 和 reorder_levels() 有什么区别?