firebase - 如何使用 Firebase 云消息发送设备到设备消息?

标签 firebase firebase-cloud-messaging

搜索文档后,我找不到任何有关如何使用 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/

相关文章:

javascript - 尝试运行我的应用程序时收到以下警告 : Possible Unhandled Promise Rejection (id:1)

firebase - 在 firestore 中使用子集合有什么好处吗?

android - Firebase 云消息传递最后一个 collapse_key 未收到(速率受限?)

firebase-cloud-messaging - Firebase 云消息传递中的 "Subject to frequency limit"标签是什么

android - 在后台或应用程序关闭时未收到 Firebase 通知

android - FirebaseMessagingService 是否默认在后台运行?

node.js - 尝试通过 Firebase Cloud Functions (Android) 发送通知后出错

java - 如何在 Android 中更新来自 Firebase 的电子邮件?

angularjs - 无法在 Controller 中使用 AngularFire 从 $firebaseObject 获取我的数据。查看/ng-repeat 工作正常

java - 如何将 Firebase 数据转换为自定义 Java 对象?