Firebase Web通知没有错误但没有通知 [英] Firebase web notifications without error but without notifications
问题描述
我订阅了Firebase项目以通过Web发送通知.
I subscribe a Firebase Project to send notifications via Web.
我准备一个HTML页面以允许通知并获取实例ID令牌.一旦获得此I.I.令牌,我使用"REST控制台"发出POST请求以发送我的第一个通知.
I prepare an HTML page to allow the notifications and get the Instance ID Token. Once get this I.I. Token, I use "REST Console" to make a POST request to send my first notification.
以上是有关请求的更多信息:
Here above more information about the request:
REQUEST URI: https://fcm.googleapis.com/fcm/send
REQUEST METHOD: POST
CONTENT-TYPE: application/json
AUTHORIZATION HEADER: key=AAAAlBHBaYo:APA91bEeEse5l9Gxhu39N...
PAYLOAD: { "notification": {
"title": "Background Message Title",
"body": "Background message body",
"click_action" : "https://www.google.com"
},
"to":"cNMqR2k1Gcs:APA91bFbK..."
}
让我解释一些关键:
-授权标头:密钥是Firebase控制台中的服务器密钥.
-JSON中的至"字段是出现在HTML页面中的实例ID令牌",在该页面中,我要求使用通知的权限.
Let me explain some key:
- Authorization header: the key is the Server Key in the Firebase Console.
- "to" field in the JSON is the Instance ID Token appeared in the HTML page where I asked the permission to use notifications.
当我执行POST请求时,得到以下响应:
When I do the POST Request I get this response:
{
"multicast_id": 5398627221409567591,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [{
"message_id": "0:1527760006779230%e609af1cf9fd7ecd"
}]
}
我想一切正常,但是我没有收到任何通知. Chrome没有显示任何内容:(
I suppose that everyting goes right BUT I didn't receive any notification. Chrome shows nothing :(
我在哪里错了?
谢谢.
推荐答案
看看chrome://gcm-internals,您看到那里收到消息了吗?
Take a look at chrome://gcm-internals, do you see a message being received in there?
这篇关于Firebase Web通知没有错误但没有通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!