I wrote my app so that when it registers, it creates the user on Firebase using email, a username and the password.
However, when the user tries to login, I can't figure out how to fetch their username from Firebase.
public void tokenAuthentication() {
fireBase.authWithCustomToken(token, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
mAuthData = authData;
final String userId = authData.getUid();
SharedPreferences.Editor peditor = myPrefs.edit();
peditor.putString("auth_token", authData.getToken());
peditor.putString("UID", userId);
peditor.commit();
Log.i("LoginActivity","SuccessAuth: UID: "+authData.getUid());
peditor.commit();
movetoMain();
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
makeToast(firebaseError.toString());
}
});
}
I tried using their onDataChanged method, but since I'm not changing data, I'm just trying to fetch, it didnt work.
Any ideas? If more information is needed, please let me know.
Thank you