1

I need to send push notifications to 100000+ registration tokens which will vary time to time.

Legacy HTTP Server Protocol documentation says in registration_ids field we can pass at most 1000 registration tokens only.

I am planning to use the HTTP v1 API to send the notification to both Android & iOS with different payload structure.

I have tried sending the notification to different platforms by passing registration tokens as an array in the tokens field to HTTP v1 API and I received notification on both Android & iOS devices successfully.

So my doubts are:

Is limit of 1000 token for registration_ids field in legacy HTTP Protocol will apply for the tokens field in HTTP v1 API also?

Can I pass all the 10000+ registration tokens to the tokens field?

If not, What can I do?

Is sending to 1000 ids in a for loop is the only solution?

Note: I can't subscribe those registration tokens to a topic, because it will lead me to subscribe the tokens to a new topic each & every time I am sending a push notification since the list of tokens may vary time to time.

Topic messaging supports unlimited subscriptions for each topic. However, FCM enforces limits in these areas:

  • One app instance can be subscribed to no more than 2000 topics.
  • If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
  • The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.

Instead of subscribing to 10000+ users in for loop by 1000 token at a time, we can directly send the messages itself in for loop for 1000 token at a time using tokens field in HTTP v1 API(which I already tried with two tokens) right?

What are you doing? What's your view? Any reference any best practice resources will be much appreciated.

Reference links:

https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages https://firebase.google.com/docs/cloud-messaging/migrate-v1

Vignesh Sundaramoorthy
  • 1,827
  • 1
  • 25
  • 38
  • Also see [this](https://stackoverflow.com/a/53300648/4625829) and [this](https://stackoverflow.com/a/50951648/4625829) – AL. Nov 29 '18 at 08:19
  • @AL. Kindly check my updated questions about the limitations of topic messaging – Vignesh Sundaramoorthy Nov 29 '18 at 10:50
  • "*I have tried sending the notification to different platforms by passing registration tokens as an array in the tokens field to HTTP v1 API and I received notification on both Android & iOS devices successfully.*" -- Like I mentioned in my answer in the duplicate post, only the parameters shown in the documentation is supported. If `registration_ids` still work, this is probably a remnant/connection to the legacy API. Continuing to use the parameter without official advise from the Google could possibly result to unexpected behaviors in the future. Use topics as strongly suggested. – AL. Nov 29 '18 at 10:58
  • @AL. Then I need to 1. Subscribe to a topic in for loop 2. Send notification to topic 3. Unsubscribe the token immediately from the topic right, but what about the `frequency of new subscriptions is rate-limit` – Vignesh Sundaramoorthy Nov 29 '18 at 11:04
  • And unsubscribing immediately won't affect sending push notification to users who are not online now right – Vignesh Sundaramoorthy Nov 29 '18 at 11:11
  • One of the answer I commented ([this one](https://stackoverflow.com/q/53283779/4625829)), is currently doing this use-case. I suggest you ask the OP there if they managed to hit that rate limit. AFAIK, as soon as the request to send the message has been enqueued to FCM, it will send it as soon as feasible. – AL. Nov 29 '18 at 11:25
  • Check this https://stackoverflow.com/a/51733245/5134215, I think the only option is to send separately for Android & iOS using legacy API in for loop and did you have any idea of what will happen if we send separately for each token using `token` field in for loop for 10000+ tokens – Vignesh Sundaramoorthy Nov 29 '18 at 11:29
  • Using the legacy API is still okay. If it suits your need best. Cheers! – AL. Nov 29 '18 at 11:47

0 Answers0