I am wondering how is push notifications system working?

Is there an active TCP/IP connection that runs in the background to Google servers?

  • 1
    See Wikipedia -- which admittedly is a little hard to read. Basically, and put in easy words: The client connects to the server and asks to be informed -- and the answer then comes "delayed" when information is available (or never if there isn't any), which then is followed by a new request. So yes, this requires a permanent background TCP/IP connection nibbling at your battery.
    – Izzy
    Mar 7, 2013 at 7:39
  • @Izzy that can't be right, because (1) the docs say an Intent is created when the message arrives, and (2) what running on Android can keep a connection open which Android can never kill?
    – Michael
    Oct 31, 2014 at 1:26
  • @Michael Which docs? I'm no Android programmer to understand the depth of it (and this is no discussion board), so I probably cannot argue with you here. I've heard that listeners (for broadcasts) can be established dynamically – but I've never heard that about intents (IMHO they have to be declared in the Manifest). I could well imagine some Google service doing the "real job", and the app simply registering a "receiver". Above description was more "general", not Android-specific, and I tried to keep it simple ;)
    – Izzy
    Oct 31, 2014 at 7:29

3 Answers 3


Yes, Android keeps one active connection to Google's servers, but it doesn't use much power or data, because no traffic is sent along it until something sends a GCM message to an app on your phone. There's only one connection on the phone, used by all apps: installing a new app that uses GCM doesn't add any extra load.

The first step in GCM is that a third-party server (such as an email server) sends a request to Google's GCM server. This server then sends the message to your device, through that open connection. The Android system looks at the message to determine which app it's for, and starts that app. The app must have registered with Android to use GCM, and it must have the relevant permission. When the app starts, it might create a notification straight away with the data from the message. GCM messages are very limited in size, so the app might instead open a normal connection to the third-party server to get more information (for example, downloading the headers of new emails).

The advantage of using push notifications is that apps don't have to run at regular intervals to check for new data, saving both power and data. The advantage of having a centralized mechanism like GCM is that the device only needs one open network connection and the Android GCM system is the only thing that needs to keep running, rather than each app having to stay running in the background to keep its own network connection to its own server.

  • 1
    I would add only 1 comment: GCM messages can be 4KByte in size, so they are not that limited. developer.android.com/google/gcm/gcm.html
    – Moszi
    May 19, 2014 at 11:27
  • What is holding this connection open? Any Android activity or service can be killed at any time.
    – Michael
    Oct 31, 2014 at 1:27
  • 1
    Thanks for the info. According to my question, Do you know what is the URL of an opened socket? (URL of the connection from device to GCM servers that is opened and use for notification data)
    – Vahid
    Oct 18, 2015 at 9:35

Android OS is now using GCM (Google Cloud Messaging) for Push Notification WS. You can get better idea here; it will give you an Architectural Overview about Full Push Notification Service with its Life Cycle.

Hope it will Help.

  • Is there a way to do a similar thing without having to rely on Google's servers?
    – Michael
    Oct 31, 2014 at 1:58
  • @Michael Using Amazon Cloud services? They seem to have a comparable concept. But for the "how to", this is the wrong place ;)
    – Izzy
    Oct 31, 2014 at 7:32

Late reply to old question but worth putting it.

GCM was deprecated on last April 2018 and google has recommended to use FCM instead which is similar to GCM.

  1. we don't need to write our own registration or subscription retry logic
  2. You can use Firebase Notifications, a serverless notifications solution with a web console that lets anyone send notifications to target specific audiences based on Firebase Analytics insights.
  3. It does have GCM’s core infrastructure.
  4. A Single message can transfer a payload of up to 4KB to a client app.
  • 1
    From app perspective FCM is not similar to GCM, it is identical. FCM is just the new name of GCM.
    – Robert
    Aug 28, 2019 at 7:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .