且构网

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

如何通过 Firebase 从用户向用户发送直接消息?

更新时间:2023-12-04 09:25:58

您建议的方法听起来不错.要实现的最重要的事情是您需要应用服务器将下游消息发送到设备.使用数据库作为应用程序和应用程序服务器之间的通信机制是一种流行的方法.

Your suggested approach sounds good. The most important thing to realize is that you require an app server to send a downstream message to a device. Using the database as the communication mechanism between the app and the app server is a popular approach.

您还可以使用 云消息传递的上游功能.但我从未尝试过这种方法,因为数据库对我来说很好用,而且我对学习另一种协议 (XMPP) 没什么兴趣.

You could also use Cloud Messaging's upstream capabilities. But I've never tried that approach, because the database works fine for me and I had little interest in learning yet another protocol (XMPP).

您可以在这篇 Firebase 博客文章中了解我是如何实现它的 在具有 Firebase 数据库和云消息传递的 Android 设备之间发送通知.

You can read how I implemented it in this Firebase blog post Sending notifications between Android devices with Firebase Database and Cloud Messaging.