Important: C2DM has been officially deprecated as of June 26, 2012.
It has been replaced by Google Cloud Messaging for Android (GCM)
This Tutorial will guide you how to create a sample simple application using the GCM functionality,
This demo will help you registering and unRegistering android device from GCM server
Getting your Sender ID
- STEP 1. Register Here .
- STEP 2. Click Create project. Your browser URL will change to something like:
" https://code.google.com/apis/console/#project:4815162342 "Take note of the value after
#project:(4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID. This Id will be used by the Android Device while Registering for Push Notification.
- STEP 3. Choose Service tab from the left side menu on the web page. and turn on “ Google Cloud Messaging for Android “
- STEP 4. Go to API Access tab from the left menu of web page.
press Create new Server key and note down the generated key
CREATING APP FOR GCM
- Update ADT plugin 20 .
- update SDK > install Extras > Google Cloud Messaging for Android Library.
- Add gcm.jar to libs folder.(will be in the android_sdk/extras/google/gcm after updating ADT and SDK)
- STEP 5. Create A new Project in Android with the following specifications
Android Version 2.2
Package = com.sagar.gcma
Main Activity = PushAndroidActivity
- Source Code for PushAndroidActivity.java:
- Source code for GCMIntentService.java :
- Source Code for CommonUtilities.java
- Source Code for AndroidManifest.xml
- SourceCode of main.xml