Firebase authentication for different kinds of users [duplicate] - android

This question already has answers here:
Check if value in Firebase Realtime Database is equal to String [duplicate]
(2 answers)
Closed 2 years ago.
I'm working on a Doctor-on-Demand kind of application and I want to use firebase for the project. I have 3 types of users and Apps:
Patients
Doctors
Admin
What are workaround on this, for example for the case of authentication each have their own custom fields.

Its not clear why you want to use firebase and for what purpose. I mean how you want to use firebase here. Please give some more detail about it.

Set the value like is_admin == 1 and is_doctors == 2 and is_patients == 3 and please give some more detail about it.

Related

How to retrieve firebase events data from the app? [duplicate]

This question already has answers here:
Can I get firebase analytics data using query?
(3 answers)
Is there any api for dashboard analytics data?
(1 answer)
Is it possible to collect data from Firebase Analytics Console programmatically?
(1 answer)
Closed 3 years ago.
In my java android app I'm recording with the firebase analytics some events that the user watches in the app, like every time the user watch an item. I would like to retrieve this data to, for example, show the user the yesterday's top most watched items. How can I achieve that?
The only information that I can find is to retrieve data from the firebase database which I'm not using. Can someone point me in the right direction?
Thanks
Just had a quick look at the below docs
https://firebase.google.com/docs/analytics/
I can't see a "get" method for receiving data. :( So I don't think they offer it right now.
You could get the same result by using the Real-Time Database.
set the value with something like: (the below is javascript but the idea will be the same)
// get next ID
id = Firebase.database().ref().child("users").push().key;
// get all users
const users = Firebase.database().ref().child("users");
var userOBJ = {};
users.on('value', function (snap) {
userOBJ[id] = {username: ..., watch_item:1234 });
users.update(userOBJ);
To get the object data
dbOBJ = Firebase.database().ref().child("users").child(id);
dbOBJ.on('value', function(snapshot){
snapshot.val();
});

How to filter collections in Firebase Firestore? [duplicate]

This question already has answers here:
Google Firestore - How to get several documents by multiple ids in one round-trip?
(17 answers)
Closed 4 years ago.
I have below FireStore data
And I have a list specialUsers which is defined as
val specialUsers = arrayOf("stark#gmail.com", "lannester#gmail.com")
So I want to get collections which are in the specialUsers, something like
collection("users").whereIn(specialUsers)
But, couldn't find any documentation related to this. How can I perform above intention in Firestore?
As he says here in 6:19
There is still no way for the database to automatically grab specific user name and profile for each review as I requesting them. I would need to make separate database request for every single review I get to fetch this information and that's bad. so If we wont to automatically include information about who rote a particular review we will need to copy sample of the user profile to the particular review and this is the way (to brake data Normalization) specifically in could FireStore.

Querying with two child in Firebase [duplicate]

This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 5 years ago.
Query q = FirebaseDatabase.getInstance().getReference().child("Chats").orderByChild("senderkey")
.equalTo(FirebaseAuth.getInstance().getCurrentUser().getUid());
In the above code I'm querying using sender = x , what if i want to make this statement senderkey = x and receiverkey = y.
In short, how to use AND in firebase ?
because:
I’m displaying the data by querying by senderkey but I don’t want to display the duplicated data again, if the senderkey is repeated i want it to be displayed once
I don't think this is possible. You can't query on multiple children. If you know you want the last message with a specific sender id you can use the limitToLast() function which will eliminate the duplicate concern.
More info on Firebase Database Queries here: https://firebase.google.com/docs/database/admin/retrieve-data
These type of queries are not allowed in firebase realtime database You can use firestore for multiple where queries by the way.
If you want to stick with firebase realtime database then you should work on your data model and create combine key to search and perform AND operation.
For example to perform AND operation you need to create a key
"name_createdAt" = "chickungunya_moka"
and then do query for
orderByChild("name_reportedAt").equalsTo(name+"_"+reportedAt);

Firebase check if user exists by display name [duplicate]

This question already has answers here:
How to get userID by user Email Firebase android?
(6 answers)
Closed 5 years ago.
I am trying to know if a user exists in Firebase (Email/Password Authentication) y only knowing the display name.
I am doing this is Android (Java).
Thank you so much!
There is no built-in support in Firebase Authentication to look up users by their display name. Given the loose definition of the meaning of the display name, it would be of limited use. Display names can't be required to be unique, since it's just a value that says how the user wants to be addressed: "When you show something from/to me, show this name next to it".
Many developers end up allowing their users to pick a username/nickname, which they then do require to be unique. If that approach make sense for your use-case too, I recommend reading some of these questions about how to accomplish this with the use of the Firebase Realtime Database:
Firebase android : make username unique
Enforcing unique usernames with Firebase simplelogin
Firebase query if child of child contains a value (a more general explanation of uniqueness in the Firebase Realtime Database)
How do you prevent duplicate user properties in Firebase?

WHERE equivalent for Firebase Realtime Database in Android [duplicate]

This question already has answers here:
Firebase android : make username unique
(4 answers)
Closed 5 years ago.
The problem I can't seem to find a straight answer to is how can I do a query on this list in the Firebase database by some field (a username in my case) to find the associated key for that user given that username is guaranteed to be a unique value.
I've read through the documentation on queries, but it looks like all of them need a key in some shape or form is that really the case? And if it is how is this normally avoided?
Thanks a million below is how my DB is designed.
Right now, in my database there is a list of user objects:
Database
-users
-{SomeUniqueKey}
-data: "some data"
-username: "user1"
-usernameThisUserIsFollowing: "user2"
+{SomeOtherUniqueKey}
You may use equalTo.
Reference: https://firebase.google.com/docs/database/

Categories

Resources