FirebaseMessaging.getInstance().token.addOnSuccessListener { result ->
if(result != null){
fbToken = result
// DO your thing with your firebase token
}
}
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
String deviceToken = instanceIdResult.getToken();
// Do whatever you want with your token now
// i.e. store it on SharedPreferences or DB
// or directly send it to server
}
});
@Override
public void onNewToken(String s) {
super.onNewToken(s);
String deviceToken = s;
// Do whatever you want with your token now
// i.e. store it on SharedPreferences or DB
// or directly send it to server
}