Firebase 消息传递:成功但未交付

Firebase Messaging : Successful but not delivered

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

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

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

Postman 中的响应

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

我的post请求如下

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,而不仅仅是 'data',如下

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

希望这对某人有所帮助。