我的应用程序现在已经设置了Firebase通知,当我发送消息时,消息会发送给我的应用程序的所有用户。 (我目前通过Firebase控制台发送消息)。我想要另一种发送不涉及Firebase控制台的推送通知的方式,并且我相信HTTP Post是一种简单的方法。如何使用HTTP Post远程发送推送通知?Firebase通知:通过HTTP发送消息Post
0
A
回答
2
,因为编辑的留言: 请务必做到不包括服务器密钥到您的客户端。有很多方法可以让“找不到那么好的人”找到它并做一些事情...... 实现这一目标的正确方法是让您的客户指示您的应用程序服务器发送通知。
您必须发送HTTP-Post到Google-API-Endpoint。
您需要以下标题:
Content-Type: application/json
Authorization: key={your_server_key}
您可以在火力地堡项目中获得的youre服务器密钥。
HTTP-POST-内容:样品
{
"notification": {
"title": "Notification Title",
"text": "The Text of the notification."
},
"project_id": "<your firebase-project-id",
"to":"the specific client-device-id"
}
示例设备ID:
cc6VGMjpIiA:APA91bGLpm5Z2p0NNh7nxttCTVd1tTsL2jObDaS9U8G1YjDjkpwkBlRLjU89ns4ujQ7rFU1Z2NshpUAX2RiQiIDKhHJdB0RtSS3H6nTT-lGEkIpzVtVzJpLIVqzSVbRjmyYlxD3BSLZl
则必须将此请求发送到https://fcm.googleapis.com/fcm/send
。 截至目前,无法使用API向所有设备发送通知。您为拥有以使用Firebase控制台。
我喜欢使用Chrome插件“邮递员”发送API请求,因为您可以保存您的HTTP请求。它非常舒适。
你也可以使用卷曲。
curl
-X POST
-d "{ "notification": {
"title": "Notification Title",
"text": "The Text of the notification."
},
"project_id": "<your firebase-project-id",
"to":"the specific client-device-id"
}"
-H "Content-Type: application/json"
-H "Authorization: key={your_server_key}"
https://fcm.googleapis.com/fcm/send
相关问题
- 1. 通过Firebase发送通知
- 2. 通过Firebase云消息向Android设备发送消息
- 3. 通过推送通知发送图像或消息
- 4. 通过HTTPS发送消息
- 5. 通过SuperSocket发送消息
- 6. 通过SIP发送消息
- 7. 通过用户属性向用户发送Firebase云消息传递通知
- 8. Android - 通过Firebase收到新的私人消息时发送通知
- 9. Firebase推送通知的通知消息的click_action不起作用
- 10. 我想通过通知发送信息
- 11. 通过HTTP POST发送XML对象
- 12. 通过HTTP发送params和Json POST
- 13. 通过URL发送JSON和HTTP POST
- 14. EBAY - 通过http post发送文件?
- 15. Firebase通知 - Firebase云消息传递
- 16. 如何通过其api发送通知或消息?
- 17. 通过发送POST
- 18. Firebase notification_key发送通知
- 19. Firebase - 发送通知(安卓)
- 20. 发送通知消息给客户端
- 21. Firebase pyfcm通过图片发送推送通知
- 22. 通过Gloox XMPP库向Google Firebase发送推送通知
- 23. iOS推送通知消息
- 24. 通过Android通知渠道使用Firebase主题消息
- 25. 当推送通知认证请求被延迟时,Firebase消息传送不发送通知
- 26. HTTP POST的通知
- 27. 是否通过HTTP或HTTPS发送iPhone推送通知?
- 28. 发送了两次Firebase推送通知
- 29. 在推送通知中发送URL Firebase
- 30. 从JavaScript/jQuery发送Firebase推送通知
这确实是一个很好的使用FCM进行POST消息的例子。请注意,由于此方法需要使用您的FCM服务器密钥,因此您不应在客户端设备上运行此代码。在客户端中暴露您的服务器密钥可能会使恶意用户找到您的密钥并以您的名义发送消息。请参阅http://stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging –
是的 - 这是一种误导。我编辑我的文章相应:) – Hannes
感谢您的答案!如果我想通过Swift代码发送这个请求,我会怎么做呢? – Bawpotter