且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Firebase Cloud Messaging 向设备发送消息?

更新时间:2022-11-26 13:37:40

更新: 现在可以使用 firebase 云函数作为服务器来处理推送通知.查看他们的文档这里

UPDATE: It is now possible to use firebase cloud functions as the server for handling push notifications. Check out their documentation here

============

============

根据文档,您必须实现一个服务器来处理设备到设备通信中的推送通知.

According to the docs you must implement a server for handling push notifications in device to device communication.

在您编写使用 Firebase 云消息传递的客户端应用之前,您必须拥有一个满足以下条件的应用服务器:

Before you can write client apps that use Firebase Cloud Messaging, you must have an app server that meets the following criteria:

...

您需要决定要使用哪种 FCM 连接服务器协议来使您的应用服务器能够与 FCM 连接服务器进行交互.请注意,如果要使用来自客户端应用程序的上游消息传递,则必须使用 XMPP.有关这方面的更详细讨论,请参阅选择 FCM 连接服务器协议.

You'll need to decide which FCM connection server protocol(s) you want to use to enable your app server to interact with FCM connection servers. Note that if you want to use upstream messaging from your client applications, you must use XMPP. For a more detailed discussion of this, see Choosing an FCM Connection Server Protocol.

如果您只需要从服务器向您的用户发送基本通知.您可以使用他们的无服务器解决方案,Firebase Notifications.

If you only need to send basic notifications to your users from the server. You can use their serverless solution, Firebase Notifications.

在此处查看 FCM 和 Firebase 通知之间的比较:https://firebase.google.com/support/faq/#messaging-difference一个>

See a comparison here between FCM and Firebase Notifications: https://firebase.google.com/support/faq/#messaging-difference