Skip to content

displayName returns null after sign up - firebase-ui-auth-1.0.0 #69

@jetav8r

Description

@jetav8r

I'm trying to add a user using the Firebase auth and it returns the displayName as null, even though it asks for it via the UI on sign up. Any ideas why and how to fix? Here's the code I am using to do this:

startActivityForResult( AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(Collections.singletonList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build()))
.build(), RC_SIGN_IN);

and in the Activity for Result....

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
// user is signed in!

        //save user
        saveUser();

        startMainActivity();
        return;
    }

save user code is as follows:

private void saveUser(){
FirebaseUser fUser = FirebaseAuth.getInstance().getCurrentUser();
final User user = new User();
if (fUser.getDisplayName() != null) {
user.setUserName(fUser.getDisplayName());
} else {
Log.e("FB_info", "User has no display name");
}
user.setUserEmail(fUser.getEmail());

    final DatabaseReference userRef = FirebaseDatabase.getInstance().getReference(FirebaseRefs.getUsersRef()).child(fUser.getUid());
    userRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if(!dataSnapshot.exists()){
                userRef.updateChildren(user.toMap());
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

}

Any idea why the display name is returning null?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions