Maximum stored non-collapsible messages on Google Cloud Messaging Servers - android

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.

Related

Limit of Bulk Firebase Cloud Messaging

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

When should I use GCM device groups versus topics?

I am looking into incorporating Google Cloud Messaging into my app. I would like to send messages to all devices associated with a user. At first, it looked like GCM's device group messaging would be the way to go. But that requires managing registration IDs and notification keys on my server. It seems like it'd be easier to use GCM's topic messaging where the topic is keyed on some shared user information like a user ID.
I intend to use GCM to send data to both Android and iOS apps. I will be sending both background "content available" (to use the Apple Push Notification terminology) messages and user-visible notifications.
What advantages are there, if any, of device group messaging over topic messaging?
I think the first point below is the only thing that makes any difference
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
Topic messages are optimized for throughput rather than latency. For
fast, secure delivery to single devices or small groups of devices,
target messages to registration tokens, not topics.
If you need to
send messages to multiple devices per user, consider device group
messaging for those use cases.

GCM: Using same account on multiple devices - what happens?

I have a question concerning Google Cloud Messaging.
When I install the same app, on two different google android devices with same google account - then both will register themselves in gcm. i am storing their regId on server.
but what happens when I send to one of the regid a message - will the second get the message too? -will one of the regid be canonical? (because of same google account on device like the other - or are they treated completely different?)
What happens when I send to one of the regid a message - will the second get the message too?
Well, no. This is because GCM not only takes into account just the Google account that you use on your phone but also identifies the particular device and the particular app you are running on it. GCM id is unique for a any given app on any given device. That is how the cloud identifies which device to push notifications to. So even if you sign in to two different devices with the same account, both will register with different keys. You use this key to identify the individual device/app.
Go to the official documentation on this to get the full info.
Sounds like you want to use User Notifications. The docs are pretty straightforward. Basically you'll need to do some work on the server side to map multiple registration ids to one "notification_key" then you use this key when pushing to Google.
Google handles pushing to the multiple devices and will even do some nice syncing type things for you.

Is GCM limit of 100-message/4-collapse-key per device or per Registration ID

There are two GCM limits according to GCM documentation. One is that the GCM server can hold up to 100 messages while device is offline.
The other one is that there can only be up to 4 collapse keys PER SENDER_ID PER DEVICE.
In our use case, we can have 5 or more different apps (each one is an APK) installed on a single device and each of them registers and obtains a GCM registration id independently (using same SENDER_ID though, as we only have one Google project on server side), does each app have its own 100/4 quota or all 5 apps share the same 100/4 quota?
If all 5 apps share the same 100/4 quota, then it is very likely that after then phone gets back on line (from sleep), one or some apps will not be able to receive any queued GCM message, in the case when there are more than 100 messages queued on GCM server (hence all deleted, leaving a single special "you-need-to-perform-full-sync" message, to which app out of 5?) or the 4-collapse-key limit kills the 5th collapse-able message.
I believe the 100/4 quota is per Registration ID (which means separate quota for each app, regardless of whether or not you are using the same sender ID for the different apps).
The documentation doesn't say that the 100/4 quota is per sender ID. It says it is per device. However, since it doesn't make sense that all the apps on a single device will share the same quota, I assume that the quota is per application per device (i.e. per Registration ID).
From the Android Developer Documentation,
GCM only allows a maximum of 4 different collapse keys to be used by the GCM server per >device at any given time.
You can specify as many collapse keys as you want. But if a message is not push to the device yet, the maximum unique collapse key stored by GCM will be 4.
The limit on GCM 4 collapse_keys and per 100 messages is per Registration ID so
the other apps will not affected.

what to include in the C2DM collapse_key filed

I'm implementing C2DM on my android push application, this is what google said about collapse_key:
"An arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. Required."
I was wondering what if i want to get all the push sent during the device offline, what should i have in the collapse_key and how can i do that?
I think you should then make a new/different collaps-key for every message. You could just have an integer that keeps getting bigger over time or you could just use the system time...
While CD2M was deprecreated in favor for GCM, take into account that at least GCM allows to have only 4 collapse keys
GCM allows a maximum of 4 different collapse keys to be used by the
GCM server at any given time. In other words, the GCM server can
simultaneously store 4 different send-to-sync messages, each with a
different collapse key. If you exceed this number GCM will only keep 4
collapse keys, with no guarantees about which ones they will be.

Categories

Resources