Hope all of you aware of this class, used to get notification token whenever firebase notification token got refreshed we get the refreshed token from this class, From follo
Simply call this method to get the Firebase Messaging Token
public void getFirebaseMessagingToken ( ) {
FirebaseMessaging.getInstance ().getToken ()
.addOnCompleteListener ( task -> {
if (!task.isSuccessful ()) {
//Could not get FirebaseMessagingToken
return;
}
if (null != task.getResult ()) {
//Got FirebaseMessagingToken
String firebaseMessagingToken = Objects.requireNonNull ( task.getResult () );
//Use firebaseMessagingToken further
}
} );
}
The above code works well after adding this dependency in build.gradle file
implementation 'com.google.firebase:firebase-messaging:21.0.0'
Note: This is the code modification done for the above dependency to resolve deprecation. (Working code as of 1st November 2020)