GCMGoogle Cloud Messaging for Android                                       Ahsanul Karim                            karim...
GCM: Introduction-GCM (Google Cloud Messaging) is a free service thathelps developers send data from servers to their Andr...
GCM: Characteristics● Allows 3rd-party application servers to send messages to their  Android applications.● GCM makes no ...
GCM: Architectural OverviewKey Terms:key terms and concepts involved in GCM are divided intothese categories:● Components ...
GCM Architecture: ComponentsComponentsMobile Device   The device that is running an Android application that uses GCM.    ...
GCM Architecture: Components
GCM Architecture: ComponentsCredentialsSender ID         A project ID you acquire from the API console to identify an     ...
GCM: Implementation1. Enabling GCM: An Android application running on a   mobile device registers to receive messages.2. S...
GCM: Implementation Steps (1)●   Goto https://code.google.com/apis/console●   Create a project: GCM_test●   Browser link h...
GCM: Implementation Steps (2)●   In the main Google APIs Console page, select Services. Turn the Google Cloud    Messaging...
GCM: Implementation Steps (3)●   In the main Google APIs Console page, select API Access. Now you can see    there is API ...
GCM: Implementation Steps (3.1)● Now we have Sender ID and API KEY  ○ Sender ID: 94384365614  ○ API KEY: AIzaSyBFhGpJswkvM...
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/distdirectory to your appli...
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 inManifest:
GCM: Implementation Steps (10)Register:Unregister:
GCM: Implementation Steps (11)Receive Message
GCM: Implementation Steps (12)Send Message from Server
Upcoming SlideShare
Loading in...5
×

GCM for Android

4,058

Published on

Ref:

Published in: Education
2 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
4,058
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
398
Comments
2
Likes
4
Embeds 0
No embeds

No notes for slide

GCM for Android

  1. 1. GCMGoogle Cloud Messaging for Android Ahsanul Karim karim.ahsanul@gmail.com
  2. 2. GCM: Introduction-GCM (Google Cloud Messaging) is a free service thathelps developers send data from servers to their Androidapplications 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 forupdates using background services
  3. 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 doesnt 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. 4. GCM: Architectural OverviewKey Terms:key terms and concepts involved in GCM are divided intothese 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. 5. GCM Architecture: ComponentsComponentsMobile 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 ofApplication implementing GCM in their applications. The 3rd-party applicationServer 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.
  6. 6. GCM Architecture: Components
  7. 7. GCM Architecture: ComponentsCredentialsSender 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 oneAccount 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 thatToken gives the application server authorized access to Google services.
  8. 8. GCM: Implementation1. 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. (well do it with php)3. Receiving a Message: An Android application receives a message from a GCM server.
  9. 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. 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. 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. 12. GCM: Implementation Steps (3.1)● Now we have Sender ID and API KEY ○ Sender ID: 94384365614 ○ API KEY: AIzaSyBFhGpJswkvMxMTElfAQeMUskG13ii7s1Q
  13. 13. GCM: Implementation Steps (4)Create new Android Project:
  14. 14. GCM: Implementation Steps (5)Copy the gcm.jar file from: SDK~PATH/extras/google/gcm/gcm-client/distdirectory to your application classpath. As external jar.
  15. 15. GCM: Implementation Steps (6)Permissions in Manifest
  16. 16. GCM: Implementation Steps (7)Add GCM Receiver
  17. 17. GCM: Implementation Steps (8)Add GCM Receiver
  18. 18. GCM: Implementation Steps (9)Add GCMIntentService extending GCMBaseIntentService and add the service inManifest:
  19. 19. GCM: Implementation Steps (10)Register:Unregister:
  20. 20. GCM: Implementation Steps (11)Receive Message
  21. 21. GCM: Implementation Steps (12)Send Message from Server
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×