GCM 'Error : Not Registered'
I succeed in testing My GCM code.
But exactly same code, I couldn't get GCM push and got:
GCM Error : Not Registered.
GCM response Not Registered
means following "If it is NotRegistered
, you should remove the registration ID from your server database because the application was uninstalled from the device or it does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIVE intents." from documentation. Check in what case you get this error, when app is uninstalled from the device or you describe incorrect broadcast receiver in AndroidManifest. You can test your GCM functionality with my test GCM server. Hope, this helps you.
If you are using a device for testing, you need to delete the InstanceID before obtaining the token and re-testing because once you overwrite your APK it de-registers that InstanceId and you get that NotRegistered error. So in your RegisterIntentService class, in the onHandleIntent function do the following:
InstanceID instanceID = InstanceID.getInstance(this);
try
{
instanceID.deleteInstanceID();
} catch(IOException e)
{
e.printStackTrace();
}
instanceID = InstanceID.getInstance(this);
The Not Registered
happens when GCM thinks the device could not handle the message. This happens if the app is uninstalled or misconfigured to handle the message:
Based on @Samik and @O'Rilla answers I would suggest following steps:
- Uninstall the current installation from Android device
- Make sure you have
<receiver>
and<sender>
are defined in<application>
node inAndroidManifest.xml
. - Make sure you have the correct
<category android:name="COM.COMPANY.YOURAPP" />
in your<receiver>
- Make sure the implementation of Receiver is right
If you really think your code is correct and still getting error
{"error": "NotRegistered"}
try un-installing app manually from phone and run it again (your device will get new registration ID).
At least in my case the problem was solved!
I had this error when I had the gcm receiver outside of the application in the manifest file. Moved the receiver into the application scope and everything worked. A very happy bunny now.
<application>
...
<receiver>
...
</receiver>
...
</application>