title: FCM: onNewToken vs FirebaseInstanceId
body: <p>Firebase has deprecated some of the messaging calls in the <code>com.google.firebase:firebase-messaging:17.1.0</code> release. This <a href="https://stackoverflow.com/questions/51123197/firebaseinstanceidservice-is-deprecated">post</a> goes over those changes nicely. </p>
  
  <p><strong>Question</strong>: Can someone tell me if is it considered bad practice to not implement <code>onNewToken</code> and instead just call the below block each app launch This probably seems excessive to Android folks but feels like home from an iOS point of view.</p>
  
  <pre><code>FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener(this) { instanceIdResult -&gt;
      // Just use this call 
      val newToken = instanceIdResult.token
      Log.i("newToken", newToken)
  }
  
  
  
  @Override
  public void onNewToken(String s) {
      super.onNewToken(s);
      // Leave this unimplemented
  }
  </code></pre>
  
  <p>I am more familiar with iOS which calls its <code>onNewToken</code> equivalent on <em>every</em> app launch. So for iOS I put logic there to determine if my backend needs to be updated.</p>
  
  <p><a href="https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId.html#getInstanceId()" rel="noreferrer">getInstanceId()</a> docs say <code>This generates an Instance ID if it does not exist yet, which starts periodically sending information to the Firebase backend</code>. This makes me assume I can just call <code>FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener</code> each launch.</p>