displayName showing null after creating user with Firebase Auth

前端 未结 2 1176
予麋鹿
予麋鹿 2021-01-06 15:47

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? H

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 16:15

    You Can Also Get Name From firebaseAuthWithGoogle Method.

      private void firebaseAuthWithGoogle(final GoogleSignInAccount acct) {
      AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener() {
                    @Override
                    public void onComplete(@NonNull Task task) {
    
                        if (!task.isSuccessful()) {
    
                            Toast.makeText(MainActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            System.out.println(acct.getDisplayName());
                            System.out.println(acct.getPhotoUrl());
                        }
    
                    }
                }); }
    

提交回复
热议问题