android – 发送邮件时的Google FCM Invalid_argument

前端之家收集整理的这篇文章主要介绍了android – 发送邮件时的Google FCM Invalid_argument前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试弄清楚如何使用Firebase向Android发送推送通知并使用旧版HTTP(https://fcm.googleapis.com/fcm/send)进行工作,但文档建议使用较新的端点(https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send).我似乎无法让它工作,因为我一直得到这样的回应:

{
    "error": {
        "code": 400,"message": "Request contains an invalid argument.","status": "INVALID_ARGUMENT"
    }
}

这是在https://firebase.google.com/docs/cloud-messaging/send-message#send_messages_to_specific_devices使用样本时发生的:

POST https://fcm.googleapis.com/v1/projects/project-916177026973/messages:send HTTP/1.1
cache-control: no-cache
Postman-Token: 81403929-77ba-4568-8681-a854527ccb22
Content-Type: application/json
Authorization: Bearer 

我还尝试删除最后一个逗号以使其符合JSON并仍然没有运气.有任何想法吗?

最佳答案
正如OP指出Firebase现在建议FCM v1端点,如果你想通过HTTP发送消息.

To send messages via HTTP,send an HTTP POST request to the FCM v1
endpoint and specify the send method. The endpoint URL must contain
the project ID of the Firebase project for your app,available in the
General project settings tab of the Firebase console.

它看起来像这样:

POST https://fcm.googleapis.com/v1/projects/your_project_id_here/messages:send HTTP/

URL your_project_id_here的部分是您的项目ID.您需要在常规选项卡下找到项目特定项目ID,该项目位于Firebase控制台的“设置”部分中.

寻找项目ID.如果您对正确的项目ID有任何疑问,那么如果网站中的URL指向您的项目,它也是一个部分.看起来像:

https://console.firebase.google.com/project/your_project_id_here/settings/general/android:your_project_name
原文链接:https://www.f2er.com/android/430177.html

猜你在找的Android相关文章