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.
问题:
回答1:
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.