Number of GCM message in Android - android

I have implemented the GCM in Android, I want to know suppose I have more than 10K+ users of my app and I want to push the GCM to users simultaneous.
What it is the limit of number of GCM messages in the Android in a day. Any idea ?

There's not any limit in amount to send messages, after the change from C2DM to GCM. However, there actually is a limit in the number of pending messages to deliver if the message can't be delivered in the moment you send it, up to 100.
As per the GCM documentation:
Note: There is a limit on how many messages can be stored without collapsing. That limit is currently 100. If the limit is reached, all stored messages are discarded. Then when the device is back online, it receives a special message indicating that the limit was reached. The application can then handle the situation properly, typically by requesting a full sync.

Related

PunNub - Best way to recover lost messages when device was turned off?

We have multiple mobile clients (ios and android) subscribed to a channel-msg.
7 messages are being published to channel-msg by the server:
Messages 1-3 were published to channel.
The device got messages 1-3 via native PubNub.
The user turned the device off.
Messages 4-5 were published to channel.
The user turned the device on, and app in foreground.
Message 6 is published.
Message 6 arrives to the device.
At this point (in the "got PubNub message" callback in the device's code), I don't want to perform Message 6, because I must perform Messages 4-5 first.
I can use the history() API to get the lost messages, but with this strategy I am forced to perform the "history check" on each message I receive on the device, before I can execute it.
I there a better pattern/design to handle this scenario?
PubNub History
You don't need to call history for each individual message, rather, you retrieve all missed messages (up to 100 per history call).
Just save the timetoken of the last received message in a way that you can retrieve it when the app is relaunched (NSUserDefaults). When your app is launched, just use the timetoken as the end param (nil for start param) in your history call.
If you get 100 messages returned (the max) then it is likely you have more and you need to call history again (paging through storage) and again until you receive > 100 messages.
Once you have received the last of the messages, use the timetoken of that last message (the one closest to now), use that timetoken to subscribe to get any message between the last history call and your subscribe and continue to subscribe for further messages.

GCM Messages not Syncronized

I have created an app that send messages between devices using GCM , the thing is
if i want to send several messages in a row its possible that one of the sent messages wont be sent instantly and will be delayed.
My scenario is : I have tried to send 3 messages in a row , i received the first and the third one but couldn't receive the second one !!
One day after I received the second message , how could this be possible ?
Is there any way to sync the sending ? and why it took the second message 24 hours to be received ?
Google is very clear about how you get no guarantee that a message will arrive at all.
In other words, don't depend on messages getting delivered. Your system needs to be robust enough to handle this. Perhaps periodically check. Definitely check if the backend has stored messages you did not receive yet.
If you purely rely on GCM delivering your (chat?) messages, then users will very quickly uninstall your app, because it will be faulty.

Is there any limit to push message on same device

Hello I am working on a project where GCM is being used very much to notifify users for certain actions. For this sometimes in a 1 minutes server is continous pushing notification (3-4 messages) to same device.
But I noticed that I receive everytime only 1 message then other 2-3 messages are being discarded. I'm not sure if this is intentional to avoid spamming by Google ?
Does anyone have experience of it. Please share.
Thanks in advance.
If you are sending the messages from your server with the same collapse_key, the GCM server will discard some of them if it receives a message with collapse_key X before it managed to send the last message having the same collapse_key.
If you don't use collapse key, GCM server will discard some of your messages if it accumulated over a 100 messages for the same device that haven't been sent yet.
You can read more about it here.

GCM push message with high frequency

I am planning to implement Android push notification serivce for an app that might require receiveing even two messages per device per second. I would like to know if GCM Push messaging is the way to go or should I stick to SyncAdapter or some other technology? Single device will receive up to few thousand notifications per day. Message size will be very small to 4kb limit is fine.
If it is critical that all of the messages reach the device and none are lost, GCM alone is not the right choice, since in case GCM server would temporarily lose connection with a device, there's a limit to the number of messages that would be stored for later delivery for that device in the GCM server.
Therefore, if you have to update your app that frequently, you should probably keep an open connection between your server and your app, and load data from the server periodically.
Though the GCM server limits the number of messages that will be stored for later delivery in the case of a device disconnect, you can always create a collapse_key.
According to GCM documentation, if there is already a message with the same collapse key (and registration ID) stored and waiting for delivery, the old message will be discarded and the new message will take its place (that is, the old message will be collapsed by the new one).
Essentially, if you only need the most recent push notifications rather than all prior sent, GCM is acceptable for sending push notifications with high frequency.
You can read more about this in the GCM Advanced Topics.

How to detect if GCM "collapsed" a message?

How can a receiver of a GCM message detect if the message has been "collapsed" by the GCM server using a collapse_key? Is there any feedback available? or best practise?
The goal is to create a optimal (cheapest) implementation for the "send_to_sync" pattern where the client only "syncs" if there are messages missed.
Example:
Let's say a group of 10 devices updates each other on their exact location trough GCM messages. Only the latest update is relevant, so it would be nice to have each user have its own collapse key. Because of the limit of 4 collapse keys when using GCM you can not use a collaps key per user, thus you have to create your own system and use the "send_to_sync" pattern.
It would be nice if every "send_to_sync" message contained the latest update + in indication if there are any missed messages, if not, then there is no need to sync.
The receiver can detect that a message has been collapsed by including some sort of counter in the payload. Each time the server sends a GCM message to the devices, it would increase that count by one. When a device receives a message, it would compare that count to the previous count it received. If the count grows by more than one, a sync is required.

Categories

Resources