Android-Firebase中的两种类型的用户 [英] Android - Two types of users in Firebase

查看:61
本文介绍了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.

希望有帮助.

这篇关于Android-Firebase中的两种类型的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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