如何在Web上使用firebase云消息传递

时间:2017-06-14 12:49:58

标签: javascript firebase firebase-cloud-messaging

我是firebase的新手,希望通过firebase云消息显示浏览器的通知,但问题是我混淆了写这段代码的地方::

POST /fcm/send HTTP/1.1
Host: fcm.googleapis.com
Content-Type: application/json
Authorization: key=YOUR_SERVER_KEY

{
  "notification": {
    "title": "New chat message!",
    "body": "There is a new message in FriendlyChat",
    "icon": "/images/profile_placeholder.png",
    "click_action": "http://localhost:5000"
  },
  "to":"YOUR_DEVICE_TOKEN"
}

请告诉我在哪个档案中我必须写这段代码。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

这是一个示例有效负载(请参阅参数here)。您从自己的App Server生成请求,或者在开发期间,您只需发送下游消息using PostmancURL

还可以选择使用Firebase Notifications Console