gpt4 book ai didi

firebase - 为什么在 Firebase 中使用 UID?我应该使用它吗

转载 作者:行者123 更新时间:2023-12-03 23:17:12 28 4
gpt4 key购买 nike

我知道 UID被使用是因为它是独一无二的。但是在我的应用中,都是用谷歌ID注册的,谷歌ID也是唯一的。我应该使用 UID ?

最佳答案

是的,最好使用 uid .
从文档:

您可以通过将 Google Sign-In 集成到您的应用中,让您的用户使用他们的 Google 帐户通过 Firebase 进行身份验证。

因此,在您对用户进行身份验证后,uid将在 firebase 的身份验证页面中。那个id稍后也会在 firebase 数据库中为您提供帮助,并且更易于使用和添加到数据库中。

可以很容易地使用这个:

 FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();

然后你可以使用方法 getUid()获取用户名。因此,使用它将使您的工作更轻松。

从文档:

After a user signs in for the first time, a new user account is created and linked to the credentials—that is, the user name and password, phone number, or auth provider information—the user signed in with. This new account is stored as part of your Firebase project, and can be used to identify a user across every app in your project, regardless of how the user signs in.



另请查看此链接: https://firebase.google.com/docs/auth/android/google-signin (下一步部分)

关于firebase - 为什么在 Firebase 中使用 UID?我应该使用它吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48379888/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com