I am following this to register my deivce in Firebase
Here I am trying to display and save the notification token
public class MyFirebaseInstance
May be it takes some time to generate token. If you don't get it you can generate it as follow: (Reference:https://firebase.google.com/docs/cloud-messaging/android/client?authuser=0)
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener()
{
@Override
public void onComplete(@NonNull Task task)
{
if (!task.isSuccessful()) {
Log.w(TAG, "getInstanceId failed",
task.getException());
return;
}
// Get new Instance ID token
String token = task.getResult().getToken();
//Here you will surely get the token so store it in
//sharedpreference for future use
}
});