Currently my Firebase Database looks like this below. I have three users :I want to make feature like this, when one user follow another user and the user follow him back, they will be friends.They wont be friends until they are both follower of each other. So far I have managed to make the followers/following like this :
Now I am out of clue what to do next.
相关问题
- adding sha1 in firebase app fails with error
- firebase storage cors strange Behaviour
- Firebase security rules difference between get() a
- LoginActivty with Firebase & Facebook authenticati
- How to add working directory to deployment in GitH
相关文章
- How can make folder with Firebase Cloud Functions
- Firestore Update a document field Using Rest API
- How to convert a FCM token to APNS token?
- Swift Change the tableviewcell border color accord
- App not showing Notification receiving FCM when th
- Android Studio - Get Firebase token from GetIdToke
- How to combine Firestore orderBy desc with startAf
- Remove Duplicates from an Array of GeoFire Objects
Small disclaimer: I didn't get a chance to test this, let me know if it does what you want.
Under followers and following you seem to be using push keys to add the userID of the person that's being followed or that is following. Instead, I would simply add the uid as a child and set the value of that node to something random. Then when you want an user's followers you'd get all the keys instead of all the values.
DB Structure: I omitted anything irrelevant for the sake of brevity.
I think using DB Rules would be the easiest way to do this. Using these rules, a user would only be able to write to friends/$friend if the two users in question are following each other.
Small example on how to follow someone.
And for unfollowing an user you'd do exactly the same only with
.remove()
instead of.setValue(true)
.