title: How to store firebase token on my server if user have more than one device
body: <p>I'm using this well known code to save a new firebase token on my server (from: <a href="https://firebase.google.com/docs/notifications/android/console-device#access_the_registration_token" rel="nofollow noreferrer">Retrieve the current registration token</a>):</p>
  
  <pre><code>@Override
  public void onTokenRefresh() {
  
      // Get updated InstanceID token.
      String refreshedToken = FirebaseInstanceId.getInstance().getToken();
      Log.d(TAG, "Refreshed token: " + refreshedToken);
  
      // If you want to send messages to this application instance or
      // manage this apps subscriptions on the server side, send the
      // Instance ID token to your app server.
      sendRegistrationToServer(refreshedToken);
  }
  </code></pre>
  
  <p>The problem is, that if the user installs the app on some other device, the same code will be executed and the former firebase token will be overridden by the new one.</p>
  
  <p>So I have to distinguish between the devices, but how can I do it? <a href="https://stackoverflow.com/questions/7071281/get-android-device-name">Device name</a> is for sure not unique enough for this.</p>
  
  <p><strong>EDIT</strong>: unfortunately, the suggestion by Bob Snyder did not work. The <a href="https://developers.google.com/android/reference/com/google/firebase/iid/FirebaseInstanceId#getId()" rel="nofollow noreferrer">FirebaseInstanceId#getId()</a> is always different if I remove the App data (cache) or reinstall the app.</p>