android - Firebase 获取名字和姓氏

标签 android firebase firebase-authentication

<分区>

我的问题:

我制作了一个小的 Android 应用程序,您可以在其中使用 firebase 身份验证系统进行注册和登录。 我做了这样的:

private FirebaseAuth firebaseAuth;
firebaseAuth = FirebaseAuth.getInstance()

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

Firstname Lastname: Nice video

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

最佳答案

您可以从他们的个人资料中获取用户的姓名。来自Firebase documentation on reading the user profile :

To get a user's profile information, use the accessor methods of an instance of FirebaseUser. For example:

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();
}

关于android - Firebase 获取名字和姓氏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42189383/

相关文章:

android - 如何修复在 OnCreateView() 中变为 null 的 List<>

database - Firestore 20000 个字段限制的问题

firebase - 是否可以将 Cypress e2e 测试与 firebase auth 项目一起使用?

android - 仅允许我的应用程序的用户将值从 false 更改为 true 的最安全的安全规则是什么?

android - 通过 AWS Pinpoint 向指定用户发送推送通知

Android 用户权限访问互联网

java - 抽屉导航 Activity 中的 SupportFragment 映射非常缓慢且无响应

java - 获取 { 和 } 之间的所有文本(源文本包含\n)

android - 如何向特定设备发送推送通知

Flutter 没有将新用户插入到 Firebase