A lot of applications like WhatsApp
rely on GCM
to send notifications to device when the device is idle or the app is running in background. The GCM
message just tells the app to sync from the server and then XMPP
is used to do the actual chat(delivering the payload). But is it a good decision to rely on GCM
to send messages. So in my case when one user wants to talk with another he sends my server a message and then i deliver the message to the other user through GCM
. I understand GCM
is not 100% reliable but i can ensure reliability through timeouts and acknowledgement messages. Is there anything else that might hurt me if i go completely with with GCM
.
The reason for not going with XMPP
is that it will take a lot of effort to scale an XMPP
server(which i am not much familiar with) but in case of GCM
a lot of my scaling issues are taken care of by Google.

- 5,235
- 9
- 62
- 93
-
Depends on the nature of your application, if you plan to expand your application on iPhone, Symbian etc, relying on GCM doesn't sounds good. – Chor Wai Chun May 20 '13 at 07:41
-
@ChorWaiChun So its good if want to keep it to just android? – lovesh May 20 '13 at 20:28
-
I would say its OK, so far I've never failed receiving any GCM from my server, and in my project I did also include the whole message (xml) into the payload, assigned with an ID, so when the phone connect to my server, we can still track the messages he hasn't receive in a rare case that GCM failed. – Chor Wai Chun May 21 '13 at 00:25
-
Google has recently launched GCM with XMPP support in their ccs option. From the looks of it you get the best of both worlds, GCM connection and XMPP reliability – Sauron Dec 21 '14 at 05:52
-
_"A lot of applications like WhatsApp rely on GCM"_ - WhatsApp doesn't have the proper permissions for GCM. What it probably does is using the same principle behind GCM -- keeping a long-running connection to the server for receiving messages even if in background or the phone is asleep. The incoming network packets will wake up the device enough time for the app to acquire a wake lock and persist the message. – Piovezan Feb 08 '15 at 00:01
-
@Piovezan Just wondering about your comment(I am very new to all this), because i just tested close out whatsapp in App Manager, and clear Ram, but it still receives messages with no problem, how does whatsapp still maintain the connection when it is totally closed out? Or when the phone is just booted up? – John Jun 24 '15 at 08:17
-
@John _When the app is closed out_ -- I'm not sure. _When the phone is just booted up_ -- On bootup a `BOOT_COMPLETED` event is broadcast by the system which could trigger a service that could establish a connection to the server and wait for incoming messages. – Piovezan Jun 24 '15 at 11:50
1 Answers
I use GCM to alert the client to connect. If you just rely on GCM to deliver the payload you can't track the delivery of messages as easily.
For example I utilize a very basic form of stream management in my app so I prefer to keep it to a syncing utility only and let my client/server communicate directly.
It is also not extensible, though you could probably put the xml in the message body and parse that.
I'm not sure what the guarantee on delivery is but I'd also check that out on the google side and if you use it to deliver multiple messages you'll need to make sure you incorporate the collapse_key
function into your client because GCM will consolidate your messages into one if there is a delay in sending of if you utilize a high volume.
One other thing I'm not sure on the real-timeness of GCM so I'm not sure how great it would be for a real chat-like application.
I'd consider these things before utilizing GCM for the payload delivery.
-
-
1This message/answer has been quite a while, but I am thinking to pass the message into the Push, and when the message is pushed into the App, trigger an Ajax or some form to acknowledge the server it has been received, but i am just wondering if there is a possibility that the internet connections dies "In the middle of passing the data" in the middle of GCM, and between the Ajax back to the server. (In your case GCM received, then connection dies, and how to handle it, the server gets a timeout?And Resend GCM to trigger connects?) – John Jun 24 '15 at 08:40
-
@John Jun From memory GCM is a fire and forget, i'm not sure if there is guaranteed message delivery – James W Nov 06 '15 at 03:40
-
@John can you please take a look at this quesiton, http://stackoverflow.com/questions/39953817/should-we-use-gcm-or-new-fcm-with-openfire-for-offline-pushnotification-messag I know its not a good way to ask for help, but i really needs a solution. – arslan haktic Oct 10 '16 at 08:13