Today we will learn how Google Cloud Message (GCM) works. To understand complete process flow see below image
This image explains the complete process flow of how GCM works for sending notification to mobile devices. There are total 6 steps, where steps 1 to 4 are performed only once in initial and step 5 and 6 are performed for sending message each time.
- Register app with GCM – This step is performed on mobile device. In this step app sends a request to GCM server with needed app and device information.
- Receive registration id from GCM – In response to the request sent in first step GCM sends a registration id which can be used further for sending messages from server to mobile
- Send registration id to app server – After getting registration id from GCM, app sends this registration id to the app server from where all app notification will be sent
- Save Registration id – App server can store this registration id anywhere like database or file system etc.
- Send message to GCM with registration ids – When ever app server need to send notification to the mobile device, it send a request to GCM server with message details and registration ids where this message need to be delivered.
- GCM delivers message to devices related to registration ids – When GCM receives the request it sends notification to mobile device related to registration id and mobile app can catch that message and show a notification.