GCM 'Error : Not Registered'
Solution 1
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.
Solution 2
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);
Solution 3
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
Solution 4
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!
Solution 5
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>
LKM
Updated on July 09, 2022Comments
-
LKM almost 2 years
I succeed in testing My GCM code.
But exactly same code, I couldn't get GCM push and got:
GCM Error : Not Registered.
-
Sudhanshu Gaur over 8 yearscan you please tell me how to know which ids are unregistered on the server side so that i can remove them from my DB.
-
Samik over 8 years@DB sure, there is only one way to know when you need remove registration id from your database on the server. Getting "NotRegistered" error from GCM server means that registration_id which you try to use is not valid and should be removed. Also your server should be ready to process cannonical_id response from GCM. I explained what does cannonical_id means there stackoverflow.com/questions/26826869/…
-
Samik over 8 years@DB Also you can diagnose your registration_id via my test push server 1-dot-sigma-freedom-752.appspot.com/gcmpusher.jsp
-
akshayt23 about 8 years@Samik Hi, I have a weird issue with GCM in my app. In my GCMRegistrationService when I get the token from the InstanceId API, sometimes the token returned is not valid and using it gives "NotRegistered" error. This mostly happens when the user has uninstalled the app and then reinstalls again. While debugging, I then forcefully started GCMInstanceIdListener from adb and the InstanceID API gave a new token which works. So essentially, the first token I'm getting is wrong and the second one is working. Any idea about this?
-
Samik about 8 years@user2558050 So, make sure that your client doesn't request the token too much times, it should ask just one or two (including the update App version). Second, make sure that your server correctly handles the cannonical_id field and replaces the old token with new one when it's necessary. One of thess factors can impact on appearing of "NotRegistered" error. Also, make sure that your server use the same token which was gotten by your client, i.e. your client should pass the token to server in reliable manner.
-
akshayt23 about 8 years@Samik So I'm actually using a third party service which needs GCM to send notifications to my app, we're not using GCM from our servers. So handling this is actually becoming problematic. I'm just sending the token to the third party service and if it's invalid and a NotRegistered error is thrown, there's no way for me to become aware of it. And I'm actually not requesting a token too many times, just the first time when the app is launched, and subsequently in the
onTokenRefresh()
call. I cant seem to understand why the InstanceId API gives an invalid token. -
Jeremy almost 8 yearsDo you only do this on debug builds?
-
Rhodesie almost 8 yearsYes just in debug mode
-
halfer over 7 yearsThe reason the first copy of this was deleted by a moderator is visible to you in the comments below it. Reproduced here: "Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question."
-
Alexey Shevelyov about 7 yearsIn my case the problem was solved as well! I tried deleting the InstanceID and trying the to send a request again. But I only succeeded when I uninstalled the app (and I did not have to delete the instanceID like I have been trying before)
-
RobbiewOnline almost 7 yearsStep 2 fixed mine - a silly oversight, but your answer was a time save after a couple of days of trying to find the root cause. Thanks @Roozbeh
-
kneidels about 5 yearsI am using GCM over the web and have started getting this same message recently when sending some notifications (not all). Where is this registration ID that people are talking about? I am getting this message:
{"multicast_id":63135.....,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]
and all my manifest file looks like is:{"gcm_sender_id": "10395...." }