Firebase获得名字和姓氏

Sim*_*ner 8 android firebase firebase-authentication

我的问题:

我制作了一个小型Android应用程序,您可以在其中注册并使用firebase auth系统登录.我做到了:

private FirebaseAuth firebaseAuth;
firebaseAuth = FirebaseAuth.getInstance()
Run Code Online (Sandbox Code Playgroud)

然后我使用了firebaseAuth.signinwithEmailAndPassword.现在我的问题是:我可以从用户的电子邮件帐户中获取名字和姓氏吗?喜欢在youtube上的评论:示例:

名字姓:好视频

这不是电子邮件地址,而是名字和姓氏,问候

Fra*_*len 2

您可以从用户的个人资料中获取用户的姓名。从Firebase 文档中读取用户配置文件

要获取用户的配置文件信息,请使用 实例的访问器方法FirebaseUser。例如:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
    // Name, email address, and profile photo Url
    String name = user.getDisplayName();
    String email = user.getEmail();
    Uri photoUrl = user.getPhotoUrl();

    // Check if user's email is verified
    boolean emailVerified = user.isEmailVerified();

   // The user's ID, unique to the Firebase project. Do NOT use this value to
    // authenticate with your backend server, if you have one. Use
    // FirebaseUser.getToken() instead.
    String uid = user.getUid();
}
Run Code Online (Sandbox Code Playgroud)

  • @FrankvanPuffelen 有没有办法只获取名字?如果您在每个空格处拆分字符串,您可能会得到这一点,但是有些名称(例如日语)没有空格。 (9认同)
  • 谢谢,我已经知道了这一点,但这不是我想要得到的:/ (6认同)
  • 在这种情况下,您可能想澄清您的问题。 (5认同)