Manish Kumar Sharma
Manish Kumar Sharma

Reputation: 13442

How does GCM identify a device in Push Notifications?

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?

Upvotes: 1

Views: 628

Answers (1)

Josef Adamcik
Josef Adamcik

Reputation: 5780

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.

Upvotes: 1

Related Questions