0

When using com.google.firebase:firebase-messaging:17.1.0, FirebaseInstanceIdService and getToken are deprecated(). I cant find any documentation for onNewToken() method.

What is the difference between FirebaseMessagingService.onNewToken() and having this code

FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( MyActivity.this, new OnSuccessListener<InstanceIdResult>() { @Override public void onSuccess(InstanceIdResult instanceIdResult) { String newToken = instanceIdResult.getToken(); Log.e("newToken",newToken);} }); ?

bryce04
  • 53
  • 7
  • `getInstanceId ()` Returns the `ID` and automatically generated token for `Firebase` project. – AskNilesh Jul 09 '18 at 05:18
  • yes, but is the token that I will get using `onNewToken()` the same when using `getInstanceId()`? Is it okay to use either (only one) method in getting the token? like only using `onNewToken()` then I will just store the token in sharedpreferences? thanks – bryce04 Jul 09 '18 at 05:25
  • You should definitely only use only or the other. So if you're writing new code, only use `onNewToken`. – Frank van Puffelen Jul 09 '18 at 05:55
  • Ahh, I see. I was confused because they still don't have the documentation for this. Thank you :) – bryce04 Jul 11 '18 at 06:59

0 Answers0