0

I implemented GCM server like it said in the guide and it worked well. I did all the steps and when I sent an http request to the GCM server it returned a success response.
However, every once in a while it gives me a NotRegistered response which makes me get a new registeration ID.
I should say that the the app is still under development but I don't see why small changes in the code should effect the registration and I'm working on a GenyMotion emulator if it matters.
In the guide it Says:

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.

But I'm not sure what to get from that. Is turning off the emulator or changing the code counts as uninstalling the application?

EDIT:
It's not about changing the code or reseting the emulator. I checked a certain registration id and it went fine. After a few minutes I checked it again and got "NotRegistered". Anyone?..

GM6
  • 313
  • 1
  • 5
  • 14
  • You need to get new registration ID each time you change `versionCode`. But that is covered in [the guide](http://developer.android.com/google/gcm/client.html). Also crashed/hanging `IntentService`s caused this in my project. – Eugen Pechanec Nov 11 '14 at 00:09
  • Thanks for the response. Problem is I never touched the `versionCode` – GM6 Nov 11 '14 at 00:15
  • GCM registration doesn't depend on the version code, it depends on the device.For every device of the app, there is different Gcm id. – Harsh Parikh Nov 11 '14 at 05:04
  • Obviously. As I was saying, I'm testing on an emulator, I always use the same one and I don't do any changes which I think are relative. I edited my question please have a look – GM6 Nov 11 '14 at 07:59
  • Hi @GM6!! Sorry, I saw just now your response on another post. I'm reading all responses. There are only two actions which causes "NotRegistered" states. A) Uninstallation of the app (in concrete, the nonexistence of your app package present on device) B) An explicit call to GoogleCloudMessaging unregister() method. If none of this circumstances ocurr, is not posible to receive a "NotRegistered" error, or at least it never happened to me even on GenyMotion emulators. – Martin Revert Nov 13 '14 at 00:35
  • All good @MartinRevert! Apparently it happened to more people but still no solution https://groups.google.com/forum/#!topic/android-gcm/y8M6ChLB-2E. :( – GM6 Nov 13 '14 at 07:32

1 Answers1

-1

@GM6 you should be sure that your push server remove stored registration id if GCM response include Not Registered error. Othrewise your server continue get this error while try to send message with stored regId. I've already answer on this question here

Community
  • 1
  • 1
Samik
  • 890
  • 1
  • 8
  • 16
  • Of course. Once I get `NotRegistered` I don't use that `registration id` again. In the next run I ask to get a new one. Thing is after a few times the same will happened with this `registration id` and it's getting annoying. As I asked in the main post, Does changing the code and debugging or turning off the emulator counts as uninstall? – GM6 Nov 11 '14 at 09:39
  • "Does changing the code and debugging or turning off the emulator counts as uninstall" - i assume that **no**. Just now, i try to send push messages from [test server](http://1-dot-sigma-freedom-752.appspot.com/gcmpusher.jsp) to emulator and when: 1. Turning off emulator by "Turn off" button - gcm server resonse "GCM HTTP status: 200 GCM response body: {"multicast_id":8466387466375891690,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1415699900489774%64ac3713f9fd7ecd"}]}" 2. Closing emulator - gcm server repson the same, success. – Samik Nov 11 '14 at 10:51
  • Are you sure that your emulator doesn't uninstall apps while shutdown or turning ON (wipe user data or somethink else setting)?. As to changing code, i think that GCM response "Not Registered" not affected by yours changing code. – Samik Nov 11 '14 at 10:54
  • I checked it now and it's definitely not related to reseting the emulator. I restarted it and I didn't get the `NotRegistered` error. I just wish I knew what does cause it. It happened to many times for me to ignore it – GM6 Nov 11 '14 at 20:35