Google note about GCM "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."
so how to my application should requesting a full sync?
This is completely up to you since you need to sync with third party server but
not with the GCM server.
You can follow the same procedure that how you would sync your mobile app with your server.
Related
I have a IOT project where multiple devices update their current locations to the IOT server. The server parses the hex data received and stores them in a MySQL database. I have a independent REST API server that queries this database to retrieve the current position of the device and display it on a map in Android.
Now because of the refresh rates of the device and the Android API request, there is a considerable latency in updating the positions on the map. How can I convert this to a real-time design, eliminating the need to read from the database but just directly sending the data to the Android client?
Note: Multiple android devices may request live updates of the same GPS device.
I am considering using firebase GCM push notifications to deliver the position to an Android/iOS device which has requested for the live view updates. However, I think this would be inefficient. As this would not be very stateless as I would have to monitor the list of devices currently requesting push notifications and do some handshaking to start/stop the notifications.
Can I use web sockets instead to make a connection between the android and the server app itself? Does the quality of the internet connection matter excessively here? I realize that somewhat like UDP for updating the position the most recent packet alone matters here and any skipped position data won't contribute much.
based on our discussion
I think GCM is a good enough option for this kind of problems.
Your total number of users and concurrent users are not that much, As I know there is a limitation for FCM that is " For each sender ID, FCM allows 1000 connections in parallel." you can find it here
The other limit is about number of stored messages at FCM. Offline users do not receive messages until the become online and the limit is 100 messages. so this can be a problem, but when the user become online FCM will send a message that can be handled in client, I mean you will informed of the situation so you can ask the server to send last update messages, but if the only last one is important for you, this is not the case and you do not have any problem, because the client will receive the last update very soon.
Anyway, based on GCM/FCM you just need to worry about sending messages when you will get updates. Consider that GCM is not about only push notifications, you can handle the messages inside BroadcastReceiver.With FCM, you can send two types of messages to clients: reference
Notification messages, sometimes thought of as "display messages."
Data messages, which are handled by the client app.
in this case you need to use data messages.
So, based on these information, I suggest following scenario :
Devices send updates to the server side.
server will send GCM messages for the interested clients
on the server side, you can handle the interested clients and you need to make it parallel.
Hope this helps you. if there is any other aspect we should consider, let me know.
thanks
We're building an application server which will be used to send push notifications to android and ios clients via GCM connection server. Our plan is to use HTTP interface to connect with GCM as we only want downstream messaging. could you please tell me what is the performance of GCM for HTTP interface? I'm looking for some kind of performance data like how many push notifications messages per second GCM can support? I checked GCM site but couldn't find this. Please help to guide from where i can get such data?
as per the official Google answer
The rate limit exception code indicates that you are sending messages from a backend server too frequently. To ensure a stable service, there is a per minute / per device app upper limit on the number of messages that can be sent from a backend server. This limit is set high so most well behaving apps should not be affected, all apps should however be prepared to receive this error code.
They do not specify the "actual limit" but they do say This limit is set high so most well behaving apps should not be affected so as long as you re not spamming a single device like crazy you should be ok with whatever you send at it.
However please note that you can get throttled and have the messages be delayed
I developed an app that allows to see or download some files from my VPS. Every day, I'm adding new files (one or two times per day) and I want to notify my users, that there are new files available.
I heard about Google Cloud Messaging, but there is a limit - only 100 messages can be stored. But I think that I get it wrong. This is 100 messages per one device or 100 messages in GCM server?
So far I have more than 8000 active users and I am afraid that some of them will not get notification.
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.
The 100 message limit is per device and not per application. So if you send 100 messages from your app to a specific device which is offline then all 100 will be dropped.
If I am sending out a message to a few thousand devices, it is expected at least 100 of them to be (temporarily) offline. It doesn't make sense discarding the whole batch.
Google Cloud Messaging
I am new to android and would like to seek for advice regarding to GCM as questions below:
For the third party server, is it free to use any programming language as long as follow exactly the request format to GCM server? Is there any example to refer for using asp.net?
For the non collapsed message, GCM discard all msg if exceed 100. The maximum number 100 is for total message of the only one device OR total of pending message in the third party server?
For collapsed message so called send-to-sync, If exceed this number GCM will only keep 4 collapse keys, with no guarantees about which ones they will be. I don't really got it, can anyone further explain to me with some examples?
For the time to live, it takes advantage of concept "now" or "never", the "never" is it alerting to trigger another attempt to send the same message again?
Currently I am testing the GCM with the demo sample from here, I experienced unstable of message receiving on emulator with 2.3.3v. In other words, the message could be never reached, or delay up to 15 minutes/more, or received immediately sometimes as well. Even I tried out on jumpnote and chrome to phone apps, that is same case. Can anyone share the experiences or solutions?
Is there anyway third party to get know the results when the message arrived targeted device?
To complete the registration, the Android application sends the registration ID to the application server. This process is via GCM or our personal components like web service or POST?
For the canonical ID, how does third party server get the ID of the last registration requested by application.
Much appreciate for any reply. Thanks.
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.