8

Our goal is sending notifications to groups of devices from our backend, and only from server side is possible to know which device should receive the notification.

We've done some attempts with AppCenter because we mostly work with Xamarin iOS/Android/Forms, but now we have the doubt that it's probably better to use directly Firebase API because wider and more powerful.

I see that with new version of API (HTTP V1) is not possible to send a notification to a list of tokens, feature that was available in legacy API using registration_ids parameter (https://firebase.google.com/docs/cloud-messaging/send-message).

Device group name (legacy protocols only)

I cannot use topics because when it's time to send the communication is a server's responsibility to prepare the "mailing list" for notifications.

I was thinking to use device group messaging (https://firebase.google.com/docs/cloud-messaging/android/device-group) but these are part of the legacy api, and I'm not sure if it makes sense/it's possible to use them with new version of API.

Is an option to send a batch of 100-200-500 push notifications each one to only one token? In theory there isn't a limit to notifications which is possible to send, but I'm worried that sending too many of them I could risk to be banned.

Is it better to use legacy API? Also AppCenter (Microsoft) uses legacy API, it's evident because of how the setup works and because from AppCenter's console it's possible to send notifications to a list of tokens, feature unavailable on Firebase's console.

Another person just asked something similar but the answer was to use topics (How to send firebase notification for all user at a time?).

Mauro Piccotti
  • 1,807
  • 2
  • 23
  • 34

2 Answers2

7

Got here from the link in your comment in my answer here. And just to reiterate my response there, when sending messages to multiple tokens with v1, the suggested approach now is to use Topics Messaging, since registration_ids is not supported.

Is it better to use legacy API?

v1 was described as the more secure, cross platform, future proof way of sending messages to FCM clients. More secure since it uses OAuth2 security model.

However, if your use-case is better with using the legacy API, then I suggest you go ahead with using it.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • Thank you. At the moment our first option would be to use the new Api but sending batch some hundreds of single requests, hoping that it works (one/two devices for a few dozens to a few hundreds of users). Do you have any experience with this approach? – Mauro Piccotti Mar 10 '18 at 23:17
  • If you're wondering if there's a limit to the request, [AFAIK, there isn't](https://stackoverflow.com/a/41560864/4625829). – AL. Mar 11 '18 at 03:38
  • Always old answers referring to legacy API, I hope that everything will work fine when we'll send hundreds of post requests in parallel (sorry for the waste of traffic). Will do an attempt, in case of problems we'll switch back to old api, maybe we are lucky and meanwhile Google will add this missing feature which was available in legacy API. Thank you. – Mauro Piccotti Mar 11 '18 at 19:43
  • The only difference between v1 and legacy was mentioned in the blogpost I linked. For the limits, IMHO, they should stay the same. Cheers! – AL. Mar 12 '18 at 03:14
  • The new http v1 api ios data messages support(and the aps support in it general) seems broken. it can send notifications but that seems to be it. they don't kind of tell that it doesn't work but don't provide a working example either and some that should work will return 400. – Lassi Kinnunen Oct 18 '18 at 06:44
  • But now legacy method is not supported anymore and will be removed in 2024. I cant use topics for my purpose, same as the thread starter. What Is a good alternative for register_ids? – labu77 Jun 22 '23 at 07:54
4

This page suggests that you should stay with the legacy API if you want to continue to use the multicast feature: https://firebase.google.com/docs/cloud-messaging/migrate-v1

Any apps that use device group messaging or multicast messaging, however, may prefer to wait for future versions of the API. HTTP v1 does not support these features of the legacy API.

Sam
  • 845
  • 7
  • 20
  • 1
    Multicast Messaging is now supported. – AWhitford Apr 05 '20 at 07:03
  • I searched for Multicast Messaging with HTTP v1 but it is not supported and Legacy Api will be removed in 2024 – Cristian Jun 21 '23 at 10:12
  • @Cristian yes, I searched for this too, because I got an email from google, that I have to move from legacy to v1 and I cant find a alternative for register_id. Please see my thread here: https://stackoverflow.com/questions/76529438/send-push-fcm-to-multiple-devices-with-curl-in-v1-api – labu77 Jun 22 '23 at 07:51
  • @labu77 I opened a thread yesterday https://stackoverflow.com/questions/76525522/fcm-http-v1-api-and-multicasting-messages – Cristian Jun 22 '23 at 10:16
  • @Cristian I have found a solution with php curl and multimessaging. Its working pretty well. Are you still interested? btw, I have the exact the same scenario as you. I send also with curl and register_ids a cronjob every 2 minutes ;) but my solution is good, you will like it :) – labu77 Jun 22 '23 at 12:20
  • @labu77 yes I want to see your solution, I need to solve the problem until 2024.. – Cristian Jun 22 '23 at 13:28
  • @Cristian ok, I will provide the solution in my topic and I will place a link in yours. I will also explain how to get the bearer access_token in php and implemnt this all together in a php curl cronjob solution. – labu77 Jun 22 '23 at 15:12
  • @labu77 Thanks. For the outh2 token I already made it – Cristian Jun 22 '23 at 15:14
  • @Cristian Here is my solution: https://stackoverflow.com/questions/76529438/send-push-fcm-to-multiple-devices-with-curl-in-v1-api/76538993#76538993 Would you please provide me your php outh2 token solution? I would like to compare it to mine. I hope my solution helps you. – labu77 Jun 23 '23 at 09:58
  • @labu77 I seen your solution, I'm looking for FCM Admin SDK from Github but it need update to new HTTP V1 Api and I don't know if will be done! The only way should be batch request, but in your solution I didn't see data field to post for example a json array. For OAuth 2.0 token I only create a function that return token using google api client library http://developers.google.com/api-client-library/php as mentioned in https://firebase.google.com/docs/cloud-messaging/auth-server?hl=en – Cristian Jun 23 '23 at 10:51
  • @labu77 the other way is to use Firebase Admin SDK with node.js – Cristian Jun 23 '23 at 11:02