Ric*_*ard 0 android kotlin firebase-authentication
如何使用 Firebase Auth 在 Kotlin 中获取当前登录的用户 ID?我想拿这个 ID 来检索所述用户的完整信息以显示在一个 Activity 中。
Run Code Online (Sandbox Code Playgroud)val user = FirebaseAuth.getInstance().currentUser if (user != null) { // User is signed in } else { // No user is signed in }
然后,您可以user.uid从获取用户个人资料的文档中获取用户的 UID,如本示例所示:
Run Code Online (Sandbox Code Playgroud)val user = FirebaseAuth.getInstance().currentUser user?.let { // Name, email address, and profile photo Url val name = user.displayName val email = user.email val photoUrl = user.photoUrl // Check if user's email is verified val 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. val uid = user.uid }
| 归档时间: |
|
| 查看次数: |
1166 次 |
| 最近记录: |