How to send one to one message using Firebase Messaging

后端 未结 5 1483
Happy的楠姐
Happy的楠姐 2020-11-22 04:30

I have been trying to read the official docs and guides about how to send message from one device to another. I have saved registration token of both devices in the Real Tim

5条回答
  •  梦谈多话
    2020-11-22 05:07

    Firebase has two features to send messages to devices:

    • the Notifications panel in your Firebase Console allows you to send notifications to specific devices, groups of users, or topics that users subscribed to.
    • by calling Firebase Cloud Messaging API, you can send messages with whatever targeting strategy you prefer. Calling the FCM API requires access to your Server key, which you should never expose on client devices. That's why you should always run such code on an app server.

    The Firebase documentation shows this visually:

    Sending messages from one device directly to another device is not supported through Firebase Cloud Messaging.

    Update: I wrote a blog post detailing how to send notifications between Android devices using Firebase Database, Cloud Messaging and Node.js.

    Update 2: You can now also use Cloud Functions for Firebase to send messages securely, without spinning up a server. See this sample use-case to get started.

提交回复
热议问题