搜索文档后,我找不到任何有关如何使用 FCM 在不使用外部服务器的情况下向设备发送消息的信息。
例如,如果我正在创建一个聊天应用程序,我需要向用户发送有关未读消息的推送通知,因为他们不会一直在线,而且我无法在后台拥有始终存在的持久服务连接到实时数据库,因为这会占用太多资源。
那么当某个用户“B”向他/她发送聊天消息时,如何向用户“A”发送推送通知?我是否需要外部服务器来完成此操作,还是可以仅使用 Firebase 服务器来完成?
最佳答案
更新:现在可以使用 Firebase 云函数作为处理推送通知的服务器。查看他们的文档 here
============
根据文档,您必须实现一个服务器来处理设备间通信中的推送通知。
Before you can write client apps that use Firebase Cloud Messaging, you must have an app server that meets the following criteria:
...
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 .
查看 FCM 和 Firebase 通知之间的比较: https://firebase.google.com/support/faq/#messaging-difference
关于firebase - 如何使用 Firebase 云消息发送设备到设备消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37435750/