我的问题:
我制作了一个小的 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();
}