Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why and how is push-notification (like GCM) battery efficient?

Wanted to understand the fundamental reasons for push-notification like Google Cloud Messaging (earlier called Google Cloud to Device Messaging) being more battery friendly, for cloud <--> device communication ?

In my view, the alternative technologies involve "polling" (over TCP/IP) while keeping the connection in CONNECTED state, using keep-alives. Or is there something better ?

My limited undertanding of GCM is that, it also uses TCP/IP and keepalives, but the client never polls the server for status. Instead the server informs the client about an incoming message, and applications who subscribe to certain type of messages, are notified of the message asynchronously. Also, the common GCM connection, is shared between multiple applications, thus allowing the device electronics to sleep / hibernate at "coordinated" times, without multiple applications keeping the electronics more "ON" (electrically active) than they need to be. Is this the correct understanding ? Or is there more to it ?

Finally, how exactly does this compare to MQTT over TCP/IP with keepalives ? What are the reasons for MQTT being (apparently) less battery efficient than GCM ?

like image 816
bdutta74 Avatar asked Mar 26 '14 14:03

bdutta74


People also ask

Do push notifications use more battery?

Limit your push notifications From breaking news to food delivery updates, notifications are how you stay connected and in the know. But if too many alerts are active, they can drain your Android battery. To turn off push notifications from an app: Go to Settings > Notifications (or Apps & notifications).

What is GCM push notification?

Google Cloud Messaging (GCM) was a mobile notification service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications that target the Google Android Operating System, as well as applications or extensions developed for the ...

What are the benefits of push notifications?

A major benefit of push notifications is that they provide a direct engagement channel that increases retention. To receive push notifications from your app, a user must either have your app downloaded or have already visited your website and opted-in to receive notifications.

Why do we need GCM?

GCM provides confidentiality and authenticity for the encrypted data and authenticity for the additional authenticated data (AAD). The AAD is not encrypted. GCM mode requires that the IV is a nonce, i.e., the IV must be unique for each execution of the mode under the given key.


1 Answers

One of the main reasons it's efficient is it scales well. The android device keeps a single connection open to GCM servers to listen for notifications for ALL apps on the device, and then routes messages to the appropriate applications they are intended for. This is much more scalable and efficient than keeping a network connection open for every single application wanting to have some sort of push notifications.

The connection itself is likely a TCP connection that's left in an open state, even when the phone's goes idle. It can wake the device when data is received. I'd imagine there's some sort of heartbeat ping going on too that can have the connection be re-established if necessary.

The socket stuff is probably something you could do yourself, however like I said earlier the main reason for efficiency is the single connection for all apps. Very scalable.

like image 122
Redth Avatar answered Dec 20 '22 08:12

Redth