We are trying to sending promotional push messages to 8k different devices. We are getting success in response to the push notification URL https://fcm.googleapis.com/fcm/send
But only some of the users are getting this notification and not all. So is there any limitation in Firebase Cloud Messaging to send bulk push as i tried to find on Firebase documentation, but it is not written anywhere.
I tried to get the exact limit suggested by Google, but could not locate to a specific page where in Google has mentioned the limit.
However I have found one link of quora send more than 1000 push messages
According to this answer, the FCM limitations are similar to GCM.
From the GCM documentation:
...It must contain at least 1 and at most 1000 registration tokens.
So you're presumably able to send each message to 1000 devices. Since you're not limited in number of messages, you can send the same message 8 times, to 8 different lists.
#NeriaNachum's answer is referring to sending messages to multiple recipients limit when using the registration_ids parameter. From the FCM docs (which I think is what you were looking for):
This parameter specifies the recipient of a multicast message, a message sent to more than one registration token.
The value should be an array of registration tokens to which to send the multicast message. The array must contain at least 1 and at most 1000 registration tokens. To send a message to a single device, use the to parameter.
Multicast messages are only allowed using the HTTP JSON format.
However, if you use Topics Messaging instead, there is no limit. Just make sure that each of the user you intend to send a message to is properly subscribed. If you have your own App Server, you can subscribe multiple tokens using the Instance ID API (see my answer here).
You can only send it to 500 users in one go.
Better implement batching at your end.
https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/MulticastMessage
Related
I'm trying to find out if there are any limitations for the topic names for FCM. Managed to find info about the number of topics (no limitations), but nothing like length of topic name or allowed characters.
Yes, not all characters are allowed, having space between words is not allowed in topic names.
From the docs:
sending messages to a Firebase Cloud Messaging topic is very similar to sending messages to an individual device or to a user group. The app server sets the topic key in the message body with a value like yourTopic. Developers can choose any topic name that matches the regular expression: "[a-zA-Z0-9-_.~%]+"
for more info check this: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging (build request section)
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.
Yes there are limitations on FCM topic names.
FCM topic must match the following regular expression: [a-zA-Z0-9-_.~%]{1,900}.
I have an Android app, and I want it be able to receive push notifications from two different Firebase projects.
I read the blog "Working with multiple Firebase projects in an Android app" https://firebase.googleblog.com/2016/12/working-with-multiple-firebase-projects-in-an-android-app.html which talks about "Accessing the Databases from two different Firebase projects".
However, there is no info about receiving notifications from multiple Firebase projects.
So, how to integrate my app with multiple Firebase projects and receive push notifications from them?
There is actually a part in the documentation about this topic:
Receiving messages from multiple senders
FCM allows multiple parties to send messages to the same client app. For example, suppose the client app is an article aggregator with multiple contributors, and each of them should be able to send a message when they publish a new article. This message might contain a URL so that the client app can download the article. Instead of having to centralize all sending activity in one location, FCM gives you the ability to let each of these contributors send its own messages.
To make this possible, make sure each sender generates its own sender ID. See the client documentation for your platform for information on on how to obtain the FCM sender ID. When requesting registration, the client app fetches the token multiple times, each time with a different sender ID in audience field.
Finally, share the registration token with the corresponding app servers (to complete the FCM registration client/server handshake), and they'll be able to send messages to the client app using their own authentication keys.
Note that there is limit of 100 multiple senders.
I think the confusing but important part here is:
When requesting registration, the client app fetches the token multiple times, each time with a different sender ID in audience field.
In other terms, you'll have to call getToken() passing the Sender ID and simply "FCM" (e.g. getToken("2xxxxx3344", "FCM")) as the parameters. You'll have to make sure that you call this for each sender (project) that you need.
Also, note from the getToken() docs:
This is a blocking function so do not call it on the main thread.
Some additional good-to-knows:
It does not auto retry if it fails like the default one.
It returns an IOException when it fails.
I had some issues when implementing the accepted answer and hence went ahead and tried to do it on my own when I came to find a robust solution. I have shared in detail there solution here.
I've been doing so much research, but it seems like all the articles out there are either sending notifications from the console or sending a push notification to a single device.
All I want is to send a push notification using Firebase ON my client and not on the Console to everyone. Do I need a server? If so, what information do I need to retrieve from it?
If you simply want to send a downstream message, you don't really need a server. You can simply use Postman or cURL. Just specify the registration token(s)/topic you want to send your message payload to.
If you are aiming to send the downstream message from the client (Android app) itself, I would strongly advise not to. Quoting a portion of #FrankvanPuffelen's answer here:
Sending a message to devices (so-called downstream messages) requires a HTTP call that specifies the server key. As its name implies, this key should only be used in environments you can trust.
It is to avoid exposing the key to unauthorized users, preventing exploitation.
In the Google Cloud Messaging documentation about Messages with Payload I found the following information:
GCM will store up to 100 non-collapsible messages. After that, all messages are discarded from GCM, and a new message is created that tells the client how far behind it is.
But I can't find anything whether the 100 non-collapsible messages is the limit for the whole project or just per device?
best regards,
Phil
I think the limit if for per device, because the collapse key is also associate with registration ID.
Registration ID is tied to a particular Android application running on a particular device.
Also to note from the documentation:
However, if you use collapsible messages, remember that GCM only allows a maximum of 4 different collapse keys to be used by the GCM server per device at any given time. That potentially indicates that the messages are tie to per device.
I'm new in GCM. I would like to send an message to all devices that have the app installed. I read about registration_id: after the first connection to GCM, google send this unique string to device. I'm a beginner in server world but if I'm not mistaken, in server side, for sending a notification to devices I have to send array of registration_id and the message to google.
Google knows how has the registration id?
Is there a way to send messages to all devices without pass the registrarions id?
Thank you.
With GCM 3.0 it's now possible to send a notification to all devices thanks to topics support. The app must suscribe to one or more topics and the server can send notifications to that topic without specifying individual devices.
https://developers.google.com/cloud-messaging/topic-messaging
You can suscribe all devices to a topic called "global" and then send the message to "/topics/global" instead of sending them to all the registration_ids.
Is there a way to send messages to all devices without pass the registrarions id?
No way.
After successfully registering on GCM, you (the Android application) should send the registration id to your application server and store them somewhere, in a database for example. This registration id will be used to send a notification to a particular device.
To send a notification to all devices, would mean then to select all the registration ids from that database, and as you said, put them in an array and pass them further to GCM.
Update: With Firebase Cloud Messaging, it is now possible to use https://firebase.google.com/docs/cloud-messaging/android/topic-messaging to send notifications without explicitly specifying registration IDs.
You need to send the list of reg id of devices and also this list should not exceed 1000 this is a limitation of GCM if you want to send message to more than 1000 devices then you need to break the list in chunks of 1000.
YES, there is a way to send a message to all!
Just send in the 'to' field the '/topics/global' value, rather then in the 'registration_ids' field the ids.
For example in php:
'to' => "/topics/global",
and not this:
'registration_ids' => $this->devices
Create the notification_key, which identifies the device group by mapping a particular group to all of the group’s associated registration tokens(You can create notification keys on the app server).
With a notification_key , instead of sending one message to one registration token at a time, the app server can send one message to thenotification_key , and GCM then sends the message to all of the group’s registration tokens.
Also note that maximum number of members allowed for a notification_key is 20.
Google Dev site has added a new guide for this topic in particular.
https://developers.google.com/cloud-messaging/notifications#sending_downstream_messages_to_device_group
I think there is a confusion here. I had used the github sample code (app server in Java deployed to Tomcat for example) and Android app. There, I didn't "pass" or "send" any registration Id to the app server. It called the relevant APIs to retrieve the registration IDs and use them to send notifications. Why is every thread about GCM registration ID saying that one needs to pass registration IDs to 3rd party app server? I am afraid I don't agree. I think 3rd Party app server can query GCM server itself to find out which devices have registered to receive notification from a particular sender (sender id). Having to manually pass the registration IDs to 3rd party app server defeats the whole purpose of automating the process. Maybe I am missing something here or I am using the deprecated content. Anyway, how can an automated process involve manual intervention once it starts?