Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Android GCM works?

I was wondering how android push framework is able to distinguish data recieved via GCM and forward it to the appropriate android application for which it was intended ?

Can anyone let me know how it is done ?

like image 791
del_champ Avatar asked Aug 07 '16 08:08

del_champ


People also ask

What is GCM and how it works?

Google Cloud Messaging functions using server APIs and SDKs, both maintained by Google. The GCM has the ability to send push notifications, deep-linking commands, and application data. Larger messages can be sent with up to 4 KB of payload data.

Is GCM and FCM same?

Firebase Cloud Messaging (FCM), formerly known as Google Cloud Messaging (GCM), is a cross-platform cloud solution for messages and notifications for Android, iOS, and web applications, which as of June 2022 can be used at no cost.

How does Google Cloud Messaging work?

PRO TIP: Google Cloud Messaging for Android (GCM) is a service that allows developers to send data from their servers to their users' devices, and vice versa. GCM is completely free, and you can use it to send or receive any data, up to 4kb in size. You can then add recipients, recipients' addresses, and messages.

Why do we need GCM?

GCM can take full advantage of parallel processing and implementing GCM can make efficient use of an instruction pipeline or a hardware pipeline. By contrast, the cipher block chaining (CBC) mode of operation incurs pipeline stalls that hamper its efficiency and performance.


1 Answers

You question : how android push framework is able to distinguish data recieved via GCM and forward it to the appropriate android application.

From your question it looks like you willing to know about data workflow & Client Server architecture that exists in applications which are using the GCM service.

As per google’s documentation “Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices”. GCM is a service provided by Google for developer that helps developer to send data from server to any number of Android devices.

Simplified Application Specific Work-flow:

The push notification can be broadcasted either to the mass audience or a select set of users. Mass audience is targeted when the notification has to be sent about a marketing campaign. A subset of users are targeted when a personalized information has to be sent.

Simplified Application Specific Work-flow

The below steps explains how push notification works on android devices:

  1. First android device sends sender id, application id to GCM server for registration.
    1. Upon successful registration, GCM server issues registration id to android device.
    2. After receiving registration id, device will send registration id to our server.
    3. Our server will store registration id in the database for further use.
    4. Whenever push notification is needed, our server sends a message to GCM server along with device registration id (which is stored earlier in the database).
    5. GCM server will deliver that message to respected mobile device using device registration id.

This can also be understand using following figure enter image description here

An Example Workflow: Sample WorkFlow

So, from above images it easy to understand that whenever the android application is first installed by the user, then it registers itself to GCM server, and obtains unique GCM ID, then it's our Host servers responsibility to keep this newly registered Registration ID of the android user into Database, and then it will be used whenever server side application willing to send the message to that particular android user.

So, let us consider one case; suppose an Server wants to send Some data to Android User, which has already registered it's GCM ID 1234567 when it's first time installed, and as it's in the server's database the server application will fetch it from DB, and simply make a HTTP POST request to the GCM server in JSON format, which will have registered user's GCM ID along with the data to send , in same way the GCM Server has the record of all the Registered GCM/Android Clients, it directly forwards that message to the intended android user, and android app in user's phone will raise and Notification alert, to indicate an push notification has arrived.

Hope This answers an question!

like image 166
U.Swap Avatar answered Oct 10 '22 22:10

U.Swap