title: How to get Canonical ID from GCM
body: <p>I am trying to get a unique ID for my device so I can get push notifications from my server.</p>
  
  <p>As all turorials say : I register using GMC:</p>
  
  <pre><code>  GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    String regid = gcm.register(PROJECT_NUMBER);  // &lt;---- duplicated if uninstalled/ reinstalled
    SendRegIdToServer(regId);
  </code></pre>
  
  <p>Now, I send the regId my server and save on device.</p>
  
  <p>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.</p>
  
  <p>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 ?</p>
  
  <p>I am using gcm.register and using that ID, which obviously is duplicating on the server.</p>
  
  <p>Appreciate any help.</p>