0

On Firebase doc i can see this information

Client apps can send messages upstream to device groups by targeting messages to the appropriate notification key in the to field.

The following call to FCM sends an upstream message to a notification key. The object consists of key-value pairs.

FirebaseMessaging fm = FirebaseMessaging.getInstance();
String to = aUniqueKey; // the notification key
AtomicInteger msgId = new AtomicInteger();
fm.send(new RemoteMessage.Builder(to)
  .setMessageId(msgId)
  .addData("hello", "world")
  .build());

I create a notification key, to send message. My notification key works when I use postman. But when I use the code above from my Android app, it doesn't do anything. I do not even get an error.

Numerous discussion here on SO is saying Firebase doesn't support device to device messaging. Like here or here or here.

But, my confusion arise from above documentation. What am I missing here?

Community
  • 1
  • 1
minhaz
  • 4,233
  • 3
  • 33
  • 49
  • Why not send the message upstream to a server, and then make the server send the message to the group/device you are trying to reach? Here's a great article: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html – Kolten Sturgill Sep 16 '16 at 16:46

1 Answers1

2

The above code is in the section labeled Sending upstream messages to device groups. In the context of Firebase Cloud Messaging an upstream message is a message from a device that is sent to your app server.

To deliver these messages to the devices, you will need an app server that receives the upstream message and then distributes it to the targeted devices. See the section in the documentation labeled Receive XMPP messages on the app server.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • So the device group is basically server group? And, How it would be a server group, if i have only one id for my project? Still it is not clear what will be the benefits of sending this kind of message from device? – minhaz Sep 18 '16 at 18:31