我前段时间写了一个应用程序,现在我需要使用推送通知。我使用Firebase
来接收通知;到目前为止,非常好。
现在,我需要我的应用程序的管理版本才能创建这些通知,而不是通过控制台发送它们。 This documentation说我应该创建一个POST
请求,但它没有解释我要发布到哪个URL。
要使用的网址是什么?
答案 0 :(得分:1)
看看:
POST REQUEST:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{ "data": {
"score": "5x1",
"time": "15:10"
},
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
to是设备密钥。 Autorization标头是您的FCM密钥。
答案 1 :(得分:1)
要像firebase控制台一样发送通知,请像这样发出POST请求
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}
将“通知”用作关键字
非常重要请参阅:https://firebase.google.com/docs/cloud-messaging/concept-options