1

Here is my way of thinking: Every device present on Web has to have an IP address if it wants others to send a HTTP(or other type of) request to it and respond in turn to sender. Here, this device identifier is IP Address rather than something like MAC Address.

For Push Notifications, I have read that there is a long polling TCP socket connection open to Google's server that enables receiving of Push Notifications.

But how...magically?

I know that IP address would work more in case where I send a request and expect a response or if the IP has a Domain linked than the domain serves as a ID for the server. But, my phone doesn't have a domain name linked and the IP can change easily.

What is that "ID" that enables Google's server to send the notification to me?

Manish Kumar Sharma
  • 12,982
  • 9
  • 58
  • 105
  • 1
    You need to register a push notification id when your application launches. See [here for details.](https://stackoverflow.com/a/41024102/3145960) – Reaz Murshed May 08 '18 at 13:01

1 Answers1

1

The first trick is, that it's the device who opens the connection.

Than every application which wants to receive a notification must register with the device(system) and obtain a token (which is unique for device/user and application). This token acts as address for this particular application. System knows all those tokens registered by all those applications so it can say to the google servers: "Here is a list of all tokens this devices wants to listen to."

And the application must send this token to it's backend, so the backend knows the address of the device too.

Josef Adamcik
  • 5,620
  • 3
  • 36
  • 42
  • Then when the device (actually, Google Play app) initiates the TCP connection towards a GCM server, it needs to provide those registration tokens along with the connection so GCM servers knows which open connection(s) to sent the message to when they receive one? – stdout Mar 06 '20 at 16:08
  • 1
    @stdout Exactly, or et least something along those lines. Keep in mind that the current implementation is not open source and may differ in details. – Josef Adamcik Mar 18 '20 at 14:34