我已在中创建了我的应用程序 Firebase 并为云消息配置。 当我从发送通知时 火力基地 控制台,设备会收到通知,但如果我尝试通过Rest API发送(使用PostMan)。 然后通知不会到达设备,但响应显示为成功。
Firebase
火力基地
这是我的邮递员要求
乌里- https://fcm.googleapis.com/fcm/send Header:Content Type:application/json Authorization:key=MY_SERVER_key 正文:{“data”:{“title”:“Firebase”,“detail”:“我是Firebase”}, “to”:“我的FCM令牌在这里”} 回应:{ “多播id”:7834540847388366233, “成功”:1, “失败”:0, “规范ID”:0, “结果”:[ { “消息id”:“0:1532422122326299%ebf5f25ef9fd7ecd” } ] }
乌里- https://fcm.googleapis.com/fcm/send
Header:Content Type:application/json Authorization:key=MY_SERVER_key
正文:{“data”:{“title”:“Firebase”,“detail”:“我是Firebase”}, “to”:“我的FCM令牌在这里”}
回应:{ “多播id”:7834540847388366233, “成功”:1, “失败”:0, “规范ID”:0, “结果”:[ { “消息id”:“0:1532422122326299%ebf5f25ef9fd7ecd” } ] }
我已经搜索过了,似乎文档中提到的方式与下面的相同 有人能告诉我为什么不起作用吗? 谢谢
我在这里发帖是为了指导别人。根据@rv7284的指引,我们需要将数据发送到 notification 钥匙,而不是其他钥匙。
notification
因此,当请求主体时,其他请求参数(如header和all)应与问题中提到的相同。
{ "notification": { "title": "Firebase", "detail": "I am firebase" }, "to" : "YOUR FCM TOKEN" }