Reputation: 3788
I am trying to use GCM and everything is working fine except for the GCMRegistrar.getRegistrationId call on difference devices. I've run this code on an emulator and 2 different phones and GCMRegistrar.getRegistrationId always returns the same string. I expected it to differ on each device but it does not. Am I doing something wrong? Here's the code I'm using (taken from the docs).
GCMRegistrar.checkDevice(context);
final String regId = GCMRegistrar.getRegistrationId(context);
if (regId.equals("")) {
GCMRegistrar.register(activity, "123456789012"); //sender id/api project id
} else {
LogUtil.info("Already registered");
}
When I first ran this on the emulator GCMRegistrar.getRegistrationId returned "" but on subsequent calls it returns the big id. That makes sense. The strange thing was that when running the same code on the 2 phones, they both returned that same id (the one the emulator returned), having never run this app before.
Upvotes: 0
Views: 2758
Reputation: 10203
From what I know, the registration ID is used to match a user+device. On emulators, you don't have any user account, and the device is virtual so my guess is that the registration thinks both virtual devices are the same.
I don't know what they use to create the registration ID, but if they use the ANDROID_ID, it's a known problem that all virtual devices have the same ID.
Also it's a known problem that some manufacturers use the same device ID for all their devices although it is supposed to be unique. But maybe they are using something else. Maybe you should try to ask GCM support for this particular issue.
Upvotes: 3
Reputation: 3788
This actually turned out to be a mistake on my part on how I was checking the id's. XGouchet, thanks for your response though.
Upvotes: -1