Android-Firebase中的两种类型的用户

Android-Firebase中的两种类型的用户

问题描述:

我正在使用Firebase开发一个简单的android应用程序.我想将用户保存在实时数据库中,而不使用带有电子邮件和密码的身份验证.我只是想通过单选按钮选择他们的姓名和角色(例如,老师和学生).后来我想在列表中显示所有用户,但我想知道应该如何设置数据库以及如何根据他们的角色显示正确的活动

I am developing a simple android application with Firebase. I want to save the users in the real time database without using authentication with email and password. I simply want their name and their role (eg. teacher and student) picked by radiobuttons. Later I want to display all users in a list, but I was wondering how the database should be set up and how to display the right activity based on their role

应该是:

User
 "something"
   username: "name"
   role: "Teacher"

User
  "KA2aslkdajsdlsad"
    username: "name"
    role: "teacher"

您肯定需要使用第二个选项.您需要为所有这些用户使用唯一的标识符.为了获得新的唯一密钥(基于时间),我建议您使用push()方法.它也完全在客户端上生成,而无需与服务器协商.

Definitely you need to use the second option. You need to use a unique identifier for all those users. For achieving a new unique key (based on time), i recomand you using push() method. It's also generated entirely on the client without consultation with the server.

另一方面,我建议您使用 Firebase匿名身份验证

On the other hand i recomand you using Firebase Anonymous Authentication.

希望有帮助.