Ali*_*Ali 2 firebase firebase-cloud-messaging
我在 firebase Messaging - Documentation 这里创建了一个设备组 并取回notification_key
现在,当我使用notification_keyFirebase 控制台使用它发送消息时,它们会被发送并传递到所有注册的设备。
但是在控制台之外(例如在邮递员中)做同样的事情是行不通的,但是我确实得到了所有设备的成功消息和零故障,但设备从未收到该消息。
邮差回复
{
"success": 7,
"failure": 0
}
Run Code Online (Sandbox Code Playgroud)
我的帖子请求如下
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 !"
}
}'
Run Code Online (Sandbox Code Playgroud)
我觉得我错过了一些东西,但根据提供的文档,它应该需要发送消息
来自 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!",
}
}
Run Code Online (Sandbox Code Playgroud)
当我收到成功消息但该消息从未传递到设备时,知道这里出了什么问题吗?
我必须传递notification而不只是“数据”,如下所示
"to" : "notification_key",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
}
Run Code Online (Sandbox Code Playgroud)
希望这对某人有帮助。
| 归档时间: |
|
| 查看次数: |
2861 次 |
| 最近记录: |