gpt4 book ai didi

Firebase 消息 : Successful but not delivered

转载 作者:行者123 更新时间:2023-12-02 00:10:27 25 4
gpt4 key购买 nike

我在 firebase 消息传递中创建了一个设备组 - Documentation here并取回 notification_key

现在,当我使用 notification_key 通过 Firebase 控制台发送消息时,它们会被发送并传送到所有已注册的设备。

enter image description here

但是在控制台外(例如在 postman 中)做同样的事情是行不通的,但是我确实收到了所有设备的成功消息和零故障,但设备从未收到消息。

Postman 中的响应

{
"success": 7,
"failure": 0
}

我的发帖请求如下

curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=***' \
-H 'Content-Type: application/json' \
-d '{
"to": "my_notification_key",
"data": {
"hello": "test !"
}
}'

我觉得我错过了一些东西,但根据 provided documentation发送消息所需的一切

来自 Firebase 文档

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{
"to": "aUniqueKey",
"data": {
"hello": "This is a Firebase Cloud Messaging Device Group Message!",
}
}

当我收到成功消息但消息从未传送到设备时,知道这里出了什么问题吗?

最佳答案

我必须传递 notification 而不是像下面这样的“数据”

"to" : "notification_key",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
}

希望这对某人有帮助。

关于Firebase 消息 : Successful but not delivered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59316025/

25 4 0