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