SlideShare a Scribd company logo
GCM
Google Cloud Messaging for Android

                                       Ahsanul Karim
                            karim.ahsanul@gmail.com
GCM: Introduction
-GCM (Google Cloud Messaging) is a free service that
helps developers send data from servers to their Android
applications on Android devices.
-Using GCM we can push
   --lightweight message to applications telling that
   there is new data to be fetched from the server or
   --a message containing up to 4kb of payload data (e.g:
   instant messaging apps).
-This can eliminate continuous query to server for
updates using background services
GCM: Characteristics
● Allows 3rd-party application servers to send messages to their
  Android applications.
● GCM makes no guarantees about delivery or the order of
  messages.
● Application on an Android device doesn't need to be running to
  receive messages.
● Requires devices running Android 2.2 or higher (with Google Play
  Store application installed), or or an emulator running Android 2.2
  with Google APIs.
● Uses an existing connection for Google services. For pre-3.0
  devices, this requires users to set up their Google account on their
  mobile devices. A Google account is not a requirement on devices
  running Android 4.0.4 or higher.
GCM: Architectural Overview
Key Terms:
key terms and concepts involved in GCM are divided into
these categories:
● Components — The physical entities that play a role in
   GCM.
● Credentials — The IDs and tokens that are used in
   different stages of GCM to ensure that all parties have
   been authenticated, and that the message is going to
   the correct place.
GCM Architecture: Components

Components
Mobile Device   The device that is running an Android application that uses GCM.
                This must be a 2.2 Android device that has Google Play Store
                installed, and it must have at least one logged in Google account
                if the device is running a version lower than Android 4.0.4.
                Alternatively, for testing you can use an emulator running Android
                2.2 with Google APIs.
3rd-party       An application server that developers set up as part of
Application     implementing GCM in their applications. The 3rd-party application
Server          server sends data to an Android application on the device via the
                GCM server.
GCM Servers     The Google servers involved in taking messages from the 3rd-party
                application server and sending them to the device.
GCM Architecture: Components
GCM Architecture: Components

Credentials
Sender ID         A project ID you acquire from the API console to identify an
                  Android application that is permitted to send messages to the
                  device.

Application ID    The Android application that is registering to receive messages.


Registration ID   An ID issued by the GCM servers to the Android application that
                  allows it to receive messages.
Google User       For GCM to work, the mobile device must include at least one
Account           Google account if the device is running a version lower than
                  Android 4.0.4.

Sender Auth       An API key that is saved on the 3rd-party application server that
Token             gives the application server authorized access to Google services.
GCM: Implementation

1. Enabling GCM: An Android application running on a
   mobile device registers to receive messages.
2. Sending a Message: A 3rd-party application server
   sends messages to the device. (we'll do it with php)
3. Receiving a Message: An Android application receives
   a message from a GCM server.
GCM: Implementation Steps (1)
●   Goto https://code.google.com/apis/console
●   Create a project: GCM_test
●   Browser link has changed as https://code.google.com/apis/console/?
    pli=1#project:94384365614:services
●   it contains project id (94384365614 in this example)
●   We required that in our application as sender id.
GCM: Implementation Steps (2)
●   In the main Google APIs Console page, select Services. Turn the Google Cloud
    Messaging toggle to ON. In the Terms of Service page, accept the terms.
GCM: Implementation Steps (3)
●   In the main Google APIs Console page, select API Access. Now you can see
    there is API key if you use that key your application can receive messages from
    any server & if you want to restrict servers you can generate new server key
    using button there as “Create new server key…”.
GCM: Implementation Steps (3.1)


● Now we have Sender ID and API KEY
  ○ Sender ID: 94384365614
  ○ API KEY: AIzaSyBFhGpJswkvMxMTElfAQeMUskG13ii7s1Q
GCM: Implementation Steps (4)
Create new Android Project:
GCM: Implementation Steps (5)
Copy the gcm.jar file from: SDK~PATH/extras/google/gcm/gcm-client/dist
directory to your application classpath. As external jar.
GCM: Implementation Steps (6)
Permissions in Manifest
GCM: Implementation Steps (7)
Add GCM Receiver
GCM: Implementation Steps (8)
Add GCM Receiver
GCM: Implementation Steps (9)
Add GCMIntentService extending GCMBaseIntentService and add the service in
Manifest:
GCM: Implementation Steps (10)
Register:




Unregister:
GCM: Implementation Steps (11)
Receive Message
GCM: Implementation Steps (12)
Send Message from Server

More Related Content

PPTX
google cloud messaging
PPT
Google Cloud Messaging
PPSX
Google Cloud Messaging
PPT
Google Cloud Messaging
PPTX
Gcm presentation
PPTX
GCM Android
PPTX
Google cloud messaging
PDF
Максим Щеглов - Google Cloud Messaging for Android
google cloud messaging
Google Cloud Messaging
Google Cloud Messaging
Google Cloud Messaging
Gcm presentation
GCM Android
Google cloud messaging
Максим Щеглов - Google Cloud Messaging for Android

What's hot (16)

PPTX
GOOGLE CLOUD MESSAGING PPT 2017
PPTX
GCM with Pushbots
PPTX
Introduction to google cloud messaging in android
PPTX
FCM & GCM
PPTX
PDF
Firebase Cloud Messaging Device to Device
PPTX
GCM Technology for Android
PPTX
google cloud messaging
PPTX
Push it! How to use Google Cloud Messaging in your Android App
PDF
Google cloud messaging
PPTX
Gcm and share point integration
PPTX
Effective use of amazon web services for web deployment
PDF
Android BroadcastReceiver - How to start a service using BroadcastReceiver
PDF
Introduction to Google App Engine
PDF
Firebase on Android: The Big Picture
GOOGLE CLOUD MESSAGING PPT 2017
GCM with Pushbots
Introduction to google cloud messaging in android
FCM & GCM
Firebase Cloud Messaging Device to Device
GCM Technology for Android
google cloud messaging
Push it! How to use Google Cloud Messaging in your Android App
Google cloud messaging
Gcm and share point integration
Effective use of amazon web services for web deployment
Android BroadcastReceiver - How to start a service using BroadcastReceiver
Introduction to Google App Engine
Firebase on Android: The Big Picture
Ad

Viewers also liked (20)

PPTX
Android Workshop Day 1 Part 2
PDF
Lecture 1 Session 1 Before Getting Started
PPTX
Android GPS Tutorial
PPTX
Android MapView and MapActivity
PDF
Sensors in Android (old)
PDF
Training android
PPTX
Day 9: Make Your App Location Aware using Location API
PPT
Day 5: Android User Interface [View Widgets]
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
PPTX
Action Bar Sherlock tutorial
PPT
Day 4: Android: UI Widgets
PPTX
Android Services
PPTX
Day: 1 Introduction to Mobile Application Development (in Android)
PDF
Day 8: Dealing with Lists and ListViews
PDF
Day 2 android internals a quick overview
PPT
Day 4: Android: Getting Active through Activities
PPT
Day 6: Android BroadcastReceiver Component
PPTX
Creating the first app with android studio
PPT
Android User Interface: Basic Form Widgets
PDF
List Views
Android Workshop Day 1 Part 2
Lecture 1 Session 1 Before Getting Started
Android GPS Tutorial
Android MapView and MapActivity
Sensors in Android (old)
Training android
Day 9: Make Your App Location Aware using Location API
Day 5: Android User Interface [View Widgets]
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Action Bar Sherlock tutorial
Day 4: Android: UI Widgets
Android Services
Day: 1 Introduction to Mobile Application Development (in Android)
Day 8: Dealing with Lists and ListViews
Day 2 android internals a quick overview
Day 4: Android: Getting Active through Activities
Day 6: Android BroadcastReceiver Component
Creating the first app with android studio
Android User Interface: Basic Form Widgets
List Views
Ad

Similar to GCM for Android (20)

PDF
A Journey into Google Cloud Messaging
PDF
GCM aperitivo Android
PDF
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
PDF
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
PDF
Android chat in the cloud
PDF
Google Cloud Messaging
PPTX
Android cloud to device messaging
 
PPTX
Android Cloud To Device Messaging
PPTX
Real Time Tracking of Complete Transport System Using GPS
PDF
Push-Notification
PPTX
Remotetestingfeature v1.1
PPTX
Remotetestingfeaturev1 160109071942
PPTX
MeasureCamp London 2024 - Yasen - Measurement Protocol v2
PDF
Urban Airship & Android Application Integration Document
PDF
Urban Airship and Android Integration for Push Notification and In-App Notifi...
PPTX
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
PPTX
AutoMate+
PDF
Khadamaty_MOI_Smart_Gov_Award_Documentation
PDF
Android Cloud to Device Messaging Framework at GTUG Stockholm
A Journey into Google Cloud Messaging
GCM aperitivo Android
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
Android chat in the cloud
Google Cloud Messaging
Android cloud to device messaging
 
Android Cloud To Device Messaging
Real Time Tracking of Complete Transport System Using GPS
Push-Notification
Remotetestingfeature v1.1
Remotetestingfeaturev1 160109071942
MeasureCamp London 2024 - Yasen - Measurement Protocol v2
Urban Airship & Android Application Integration Document
Urban Airship and Android Integration for Push Notification and In-App Notifi...
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
AutoMate+
Khadamaty_MOI_Smart_Gov_Award_Documentation
Android Cloud to Device Messaging Framework at GTUG Stockholm

More from Ahsanul Karim (18)

PDF
Lecture 5: Storage: Saving Data Database, Files & Preferences
PDF
Lecture 3 getting active through activities
PDF
Lecture 2(b) Android Internals A Quick Overview
PDF
লেকচার ১ (ক)- শুরুর আগে:
PPTX
Day 15: Content Provider: Using Contacts API
PPTX
Day 15: Working in Background
PDF
Day 8: Dealing with Lists and ListViews
DOC
Day 4: Activity lifecycle
PDF
Day 1 Android: Before Getting Started
PDF
Mobile Banking in Bangladesh: An Incomplete Study
PDF
Ui layout (incomplete)
PDF
AndroidManifest
PDF
Day1 before getting_started
PPTX
Android Workshop: Day 1 Part 3
PPTX
Android 1.8 sensor
PPTX
Android before getting started
PPTX
Introduction to Android Development: Before Getting Started
PPTX
Client-Server
Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 3 getting active through activities
Lecture 2(b) Android Internals A Quick Overview
লেকচার ১ (ক)- শুরুর আগে:
Day 15: Content Provider: Using Contacts API
Day 15: Working in Background
Day 8: Dealing with Lists and ListViews
Day 4: Activity lifecycle
Day 1 Android: Before Getting Started
Mobile Banking in Bangladesh: An Incomplete Study
Ui layout (incomplete)
AndroidManifest
Day1 before getting_started
Android Workshop: Day 1 Part 3
Android 1.8 sensor
Android before getting started
Introduction to Android Development: Before Getting Started
Client-Server

Recently uploaded (20)

PPTX
master seminar digital applications in india
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Business Ethics Teaching Materials for college
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Institutional Correction lecture only . . .
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
master seminar digital applications in india
O7-L3 Supply Chain Operations - ICLT Program
Week 4 Term 3 Study Techniques revisited.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Business Ethics Teaching Materials for college
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Institutional Correction lecture only . . .
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Final Presentation General Medicine 03-08-2024.pptx
Insiders guide to clinical Medicine.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf

GCM for Android

  • 1. GCM Google Cloud Messaging for Android Ahsanul Karim karim.ahsanul@gmail.com
  • 2. GCM: Introduction -GCM (Google Cloud Messaging) is a free service that helps developers send data from servers to their Android applications on Android devices. -Using GCM we can push --lightweight message to applications telling that there is new data to be fetched from the server or --a message containing up to 4kb of payload data (e.g: instant messaging apps). -This can eliminate continuous query to server for updates using background services
  • 3. GCM: Characteristics ● Allows 3rd-party application servers to send messages to their Android applications. ● GCM makes no guarantees about delivery or the order of messages. ● Application on an Android device doesn't need to be running to receive messages. ● Requires devices running Android 2.2 or higher (with Google Play Store application installed), or or an emulator running Android 2.2 with Google APIs. ● Uses an existing connection for Google services. For pre-3.0 devices, this requires users to set up their Google account on their mobile devices. A Google account is not a requirement on devices running Android 4.0.4 or higher.
  • 4. GCM: Architectural Overview Key Terms: key terms and concepts involved in GCM are divided into these categories: ● Components — The physical entities that play a role in GCM. ● Credentials — The IDs and tokens that are used in different stages of GCM to ensure that all parties have been authenticated, and that the message is going to the correct place.
  • 5. GCM Architecture: Components Components Mobile Device The device that is running an Android application that uses GCM. This must be a 2.2 Android device that has Google Play Store installed, and it must have at least one logged in Google account if the device is running a version lower than Android 4.0.4. Alternatively, for testing you can use an emulator running Android 2.2 with Google APIs. 3rd-party An application server that developers set up as part of Application implementing GCM in their applications. The 3rd-party application Server server sends data to an Android application on the device via the GCM server. GCM Servers The Google servers involved in taking messages from the 3rd-party application server and sending them to the device.
  • 7. GCM Architecture: Components Credentials Sender ID A project ID you acquire from the API console to identify an Android application that is permitted to send messages to the device. Application ID The Android application that is registering to receive messages. Registration ID An ID issued by the GCM servers to the Android application that allows it to receive messages. Google User For GCM to work, the mobile device must include at least one Account Google account if the device is running a version lower than Android 4.0.4. Sender Auth An API key that is saved on the 3rd-party application server that Token gives the application server authorized access to Google services.
  • 8. GCM: Implementation 1. Enabling GCM: An Android application running on a mobile device registers to receive messages. 2. Sending a Message: A 3rd-party application server sends messages to the device. (we'll do it with php) 3. Receiving a Message: An Android application receives a message from a GCM server.
  • 9. GCM: Implementation Steps (1) ● Goto https://code.google.com/apis/console ● Create a project: GCM_test ● Browser link has changed as https://code.google.com/apis/console/? pli=1#project:94384365614:services ● it contains project id (94384365614 in this example) ● We required that in our application as sender id.
  • 10. GCM: Implementation Steps (2) ● In the main Google APIs Console page, select Services. Turn the Google Cloud Messaging toggle to ON. In the Terms of Service page, accept the terms.
  • 11. GCM: Implementation Steps (3) ● In the main Google APIs Console page, select API Access. Now you can see there is API key if you use that key your application can receive messages from any server & if you want to restrict servers you can generate new server key using button there as “Create new server key…”.
  • 12. GCM: Implementation Steps (3.1) ● Now we have Sender ID and API KEY ○ Sender ID: 94384365614 ○ API KEY: AIzaSyBFhGpJswkvMxMTElfAQeMUskG13ii7s1Q
  • 13. GCM: Implementation Steps (4) Create new Android Project:
  • 14. GCM: Implementation Steps (5) Copy the gcm.jar file from: SDK~PATH/extras/google/gcm/gcm-client/dist directory to your application classpath. As external jar.
  • 15. GCM: Implementation Steps (6) Permissions in Manifest
  • 16. GCM: Implementation Steps (7) Add GCM Receiver
  • 17. GCM: Implementation Steps (8) Add GCM Receiver
  • 18. GCM: Implementation Steps (9) Add GCMIntentService extending GCMBaseIntentService and add the service in Manifest:
  • 19. GCM: Implementation Steps (10) Register: Unregister:
  • 20. GCM: Implementation Steps (11) Receive Message
  • 21. GCM: Implementation Steps (12) Send Message from Server