Hope this link may solve your issue. http://captechconsulting.com/blog/antoine-campbell/google-cloud-messaging-cloud-connection-server-tutorial
Permissions Notice that GCM requires that the application define a new permission for use, com.antoinecampbell.gcmdemo.permission.C2D_MESSAGE. This permission prevents other applications from receiving the GCM message for your application.
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<permission
android:name="com.antoinecampbell.gcmdemo.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.antoinecampbell.gcmdemo.permission.C2D_MESSAGE"/>
Components The SEND permission ensures only the GCM Framework can send messages to the BroadcastReceiver. The IntentService in the demo application does the actual handling of the message it was passed by the BroadcastReceiver.
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.antoinecampbell.gcmdemo"/>
</intent-filter>
</receiver>
<service android:name=".GcmIntentService"></service>
Device Registration Before any device can be used with GCM it must first register with the GCM servers. This can be done using the GoogleCloudMessaging class within the Google Play Services library. This is a blocking call so it should be performed in the background using an AsyncTask. A registration ID will be returned that uniquely identifies the device for the ProjectID used. Registration should occur in the onCreate() method of your activity, or using a dialog if you would like to give the user a choice about receiving GCM messages. This is generally something you do only once. The demo shows how to unregister as well, though it is not a common action. The only time you may want to unregister a device is if you allow the user to opt-out of receiving GCM messages within your application.
Once the registration ID is retrieved, it should be sent to your server to be saved in a database and stored locally on the device. The demo application stores the registration ID in SharedPreferences and sends the ID off to the CCS application using a GCM message. It is recommended that this be done via HTTP so you have an immediate answer on its success or failure. The CCS application handles the same functions an HTTP server would by storing the usernames and device registration IDs.