2017-02-12 71 views
0

我的問題:Firebase獲取姓名

我做了一個小的Android應用程序,在那裏你可以註冊並使用Firebase身份驗證系統登錄。 我把它想:

private FirebaseAuth firebaseAuth; 
firebaseAuth = FirebaseAuth.getInstance()

然後我用firebaseAuth.signinwithEmailAndPassword。現在我的問題:我可以從用戶的電子郵件帳戶中獲得名字和姓氏嗎? 像在YouTube上的評論:例如:

名字姓氏:尼斯視頻

這不是電子郵件地址是在這裏,但在第一個和最後的名字, 問候

回答

1

你可以從他們的個人資料中獲取用戶的姓名。來自Firebase documentation on reading the user profile

要獲取用戶的配置文件信息,請使用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(); 
} 
+1

謝謝你,我已經知道這一點,這是不是那個意思,我想:/ –

+2

在你可能想澄清你的問題的話。 –

+1

@FrankvanPuffelen有沒有辦法只得到名字?如果你在每個空間分割字符串,你可能會明白,但是有些名字(例如日語)沒有空格。 – MScott