Reputation: 539
I created an Android application that uses GCM for Android. This application works on multiple devices. But suddenly, it stopped working on one device where it has worked before. I have problems only on that device: it no longer receives any messages. After some debugging and adjusting my code for testing, it seems that this device keeps getting new registration ids when registering on GCM (I suppose when you register a device multiple times, you receive the same registration ID?). I removed the app several times from the device, then reinstalled the app, and different registration ids were saved to my database (whereas for the other devices, it keeps the same registration ID).
When I debug the message transfer code, I notice GCM sends the message to multiple registration ids (all stored in my database for that same device) and every message gets status OK, but no message is received by my device. I'm familiar with a canonical ID, but this canonical ID is null in every result. So I suppose this is not the problem?
This problem came suddenly. I don't know what the problem is. The application keeps working on other devices, I only have this problem on 1 device.
Can anyone help me with this problem?
Upvotes: 1
Views: 1049
Reputation: 73753
GCM registration ID is not the same for a single device. GCM registration ID changes and can become invalid which is why google recommends registering again when you update your app because your current ID is not guaranteed to work.
http://developer.android.com/google/gcm/adv.html#reg-state
making a call the get a registration id may or may not return you the same registration id that you had before.
Upvotes: 0
Reputation: 285
First you should know that the id you get from GCM is not constant to your device and can change, so you you must not count on it as Primary key for anything.
when you get an id from GCM you need to save it (possibly in SharedPreferences) and then each time check if this id exist or not, if yes there is no need to register with GCM. then each time you will send a message to that id it should arrived.
Upvotes: 1