我正在尝试使用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 <token redacted>
User-Agent: PostmanRuntime/6.4.1
Accept: */*
Host: fcm.googleapis.com
accept-encoding: gzip, deflate
content-length: 319
Connection: close
{
"message":{
"token" : <token redacted>,
"notification" : {
"body" : "This is an FCM notification message!",
"title" : "FCM Message",
}
}
}
我也试过去掉最后一个逗号以符合JSON格式,但仍然没有成功。有什么想法吗?