为什么在Firebase中使用UID?我应该使用它吗 [英] Why use UID in Firebase? Should I use it

查看:113
本文介绍了为什么在Firebase中使用UID?我应该使用它吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道使用UID是因为它是唯一的.但是在我的应用程序中,所有这些都已使用Google ID注册,Google ID也是唯一的.我应该使用UID吗?

I know UID is used because it is unique. But in my app, all of them are registered with Google ID, Google ID is also unique. Should I use UID?

推荐答案

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

yes it is better to use the uid. From the docs:

您可以通过将Google登录功能集成到您的应用中,让用户使用其Google帐户向Firebase进行身份验证.

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

So after you authenticate the users, the uid will be in the authentication page in firebase. That id will help you later in the firebase database also and it is easier to use and add in the database.

可以很容易地使用它:

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

然后,您可以使用方法getUid()获取用户ID.因此,使用它会使您的工作更轻松.

Then you can use the method getUid() to get the userid. So using it will make the work easier for you.

从文档中

用户首次登录后,将创建一个新的用户帐户并将其链接到用户登录所用的凭据(即用户名和密码,电话号码或身份验证提供者信息).此新帐户存储为Firebase项目的一部分,无论用户如何登录,都可以用来在项目中的每个应用程序中识别用户.

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 (下一步"部分)

Also check this link: https://firebase.google.com/docs/auth/android/google-signin (Next Step section)

这篇关于为什么在Firebase中使用UID?我应该使用它吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆