Google Cloud Messaging and less battery drain

google-cloud-messaging

Solution

The way it works is that without GCM, your app would either have to have a socket open to your server and ping it every 5 minutes or so in order to keep the socket alive.. Another option would be to make an HTTP call to your server every 5 minutes or so to see if there's anything new to fetch..

With GCM, there's one unified process that's already running to get messages. Now your app just subscribes with a broadcast listener, then if on that GCM process there's ever a message for your app, it would be broadcasted to your app, and at that stage you can whatever you want.

This conserves battery because you are just piggybacking on the already existing GCM service on the OS instead of running your own, thus using less battery.

Problem

I've heard that GCM provides less energy consumption.How does GCM provide higher battery life exactly? What is the difference with GCM? It is said that server sends a message to app when there is something to get.So app doesnt have to check the server everytime. But now, app is still have to check for that message?

Original source