GCM 'Error : Not Registered'

54,868

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:

enter image description here

Based on @Samik and @O'Rilla answers I would suggest following steps:

  1. Uninstall the current installation from Android device
  2. Make sure you have <receiver> and <sender> are defined in <application> node in AndroidManifest.xml.
  3. Make sure you have the correct <category android:name="COM.COMPANY.YOURAPP" /> in your <receiver>
  4. 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>
Share:
54,868
LKM
Author by

LKM

Updated on July 09, 2022

Comments

  • LKM
    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
    Sudhanshu Gaur over 8 years
    can 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
    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
    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
    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
    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
    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
    Jeremy almost 8 years
    Do you only do this on debug builds?
  • Rhodesie
    Rhodesie almost 8 years
    Yes just in debug mode
  • halfer
    halfer over 7 years
    The 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
    Alexey Shevelyov about 7 years
    In 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
    RobbiewOnline almost 7 years
    Step 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
    kneidels about 5 years
    I 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,"canonica‌​l_ids":0,"results":[‌​{"error":"NotRegiste‌​red"}] and all my manifest file looks like is: {"gcm_sender_id": "10395...." }