I had the same problem with my application.
First thing that was wrong, was with my GCMIntentService. It has to be at the root of your package.
I will include here a short snippet of my GCMIntentService. Please keep in mind that, you will receive your registrationID on GCMIntentService register method
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super(CloudMessagingUtility.SENDER_ID);
}
/**
* Method called on device registered
**/
@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
//here call your methods to send the registrationId to your webserver
CloudMessagingUtility.register(context, registrationId);
}
/**
* Method called on device un registred
* */
@Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device will unregister from Google Cloud Messaging");
//unregister the device from your own webserver too
CloudMessagingUtility.unregister(context, registrationId);
}
/**
* Method called on Receiving a new message
* */
@Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message from GCM:");
String message = "";//TODO handle here the messages!
}
/**
* Method called on receiving a deleted message
* */
@Override
protected void onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
String message = getString(R.string.gcm_deleted, total);
displayMessage(context, message);
}
/**
* Method called on Error
* */
@Override
public void onError(Context context, String errorId) {
Log.e(TAG, "Received error: " + errorId);
}
}
you have to make the right configuration in the Android
e <service android:name=".GCMIntentService" /><receiver android:name="com.google.android.gcm.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=" your package here" />
</intent-filter>
</receiver>