I am trying to get a unique ID for my device so I can get push notifications from my server.
As all turorials say : I register using GMC:
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String regid = gcm.register(PROJECT_NUMBER); // <---- duplicated if uninstalled/ reinstalled
SendRegIdToServer(regId);
Now, I send the regId my server and save on device.
The problem comes when I uninstall and reinstall, since the local storage is lost, I ask GCM to register again and I get a new registration ID. Because of this, my server is having duplicates of the same device.
I looked at SO butlot of questions are on GCMRegistrar, which is deprecated now.
People say use Canonical ID, which is unique. But how do I get it ?
I am using gcm.register and using that ID, which obviously is duplicating on the server.
Appreciate any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…