What technology does GCM (Google Cloud Messaging)

2019-07-21 03:17发布

问题:

Does it work by polling the servers periodically ? Does it work using long-held http request , like comet ? Or theres some new technology they are using ?

回答1:

Here is a good overview: http://developer.android.com/google/gcm/gcm.html

Somewhere it explains that GCM is preferred to the app polling because the Android OS is doing the polling through a long-held OS connection to the GCM server. So even though they call it "push" technology it is really being polled/pulled by the device. The OS then tells the app there is a message and the app retrieves it. Google is just doing the work for all apps through one channel that the OS already uses to check for updates so the device won't be constantly polling as all apps check back to their servers if GCM wasn't used.

There are IDs that help the OS know which app needs which message and the developer needs to set up and maintain a server that helps "push" the messages to device(s). There can be broadcast type messages or messages targeting individual devices. Google outlines a couple of different types of communication mechanisms - HTTP and XMPP.

No real new technology - Google is just providing a platform/interface/architecture for developers.

This info just touches the surface - there is much more detail in the documentation.