问题
I have been researching around the web on how to create a friends list system using firebase. So far I had no luck and was given resources that was not quite what I was looking for. The premise of the app is using the User Login & Authentication to create a account(completed), then once the user has an account they can add people that are register in the firbase users. This can comparable to a friends list. once the user adds another user they can have an option to create a post that only his friends can see and the users can group chat in side the post.
The Problem:
- Don't know where to start in creating a friends list using firebase custom User Login & Authentication
- After that how do only the people that are add to the users friends list see the content posted.
P.S. just looking for some guidance on the subject from anything to resources to/ tips
回答1:
Kato's comment is on point. Being super new to Firebase can be a bit daunting so here's some ideas:
You cannot use the Login & Authentication in the way you want. It is a function that allows you to create users that can access your Firebase and that's it.
If you want to do more with users, create a /users node that contains other stuff.
users
uid_0
name: "Frank"
friends
uid_1: true
uid_2: true
uid_1
name: "Kato"
uid_2
name: "Bill"
This tells us that Frank has two friends, Kato and Bill.
To accomplish your task, Firebase will need to notify your app when new users sign up (by adding them to the users node and observing the Users node for .childAdded) and then display the new users to your user so they can add them to their friends list.
Posts can be handled in a similar fashion
posts
post_id_0
msg: "Hey look kids, there's Big Ben, and there's Parliament"
posted_by: uid_0
viewers:
uid_1: true
This structure has a post reference (created by autoId), a msg and who posted it and who's allowed to view it, in this case user with a uid_1, Kato.
Saving Data and Retrieving Data are critical reads and simply going through the well-written Firebase Guide to the Stars is a must.
Hope this provides some direction, and in the future, craft your code, create a Firebase structure and when you really get stuck, post those (as text please) as they will help us, help you.
来源:https://stackoverflow.com/questions/36023038/how-to-create-a-friends-list-using-firebase