首页 > 解决方案 > 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;
}

标签: androidfirebasefirebase-cloud-messaging

解决方案


推荐阅读