Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

android - How to get Canonical ID from GCM

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...