0

I know this post may be considered off-topic, I'm forced to ask, because I'm a little confused. My Android app subscribes some FCM topics and my server needs to send notifications with POST requests/json.

Looking here: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging we can see Google example includes endpoint like this:

https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send

However, when I started looking for full api description, I found this: https://firebase.google.com/docs/cloud-messaging/http-server-ref and endoint is like this:

https://fcm.googleapis.com/fcm/send

So I'm a little confused, which one is recommended to use?

halfer
  • 19,824
  • 17
  • 99
  • 186
user1209216
  • 7,404
  • 12
  • 60
  • 123

1 Answers1

0

Use the first link to send the payload when you need to send only to some subscribed topic/channel. Use the second link (which is mostly used) to send to devices using there registered FCM device token.

Refer to this question for more info:

Firebase Notification - send to user segment vs send to topic difference

https://firebase.google.com/docs/cloud-messaging/android/send-multiple

Tejashwi Kalp Taru
  • 2,994
  • 2
  • 20
  • 35
  • Why use first link, while I can use second one to send to single topic? – user1209216 Aug 07 '18 at 09:59
  • The first link is specific to the subscribed topic, you can't send a notification to those devices which are not registered to that topic, but are registered to FCM for some other notification (like a new message or any update), using the second API you can send notifications regardless of topic subscription, all you need is that the device is registered against your FCM – Tejashwi Kalp Taru Aug 07 '18 at 10:03
  • As far as I understand, second api allows to send to topic or to instance id, first one only to topic. So, second way is more flexible – user1209216 Aug 07 '18 at 10:07
  • yes, that's why second way is widely used on server side – Tejashwi Kalp Taru Aug 07 '18 at 10:08
  • Ok, thanks for clarify. Also first way includes project in url, so it's less flexible again – user1209216 Aug 07 '18 at 10:13