0

i am currently working on a flutter app which is kinda social media app, right now i am stuck with the idea to implement the add friends feature from a list of contacts who have account in my app, but i can not think of any method of doing so , my app's back-end is handled by Firebase with each user's profile information stored differently in Firestore database,

i want a simple and efficient way to add friends in my app, more like Facebook, Instagram, Snapchat,

can anyone suggest me how to implement this feature in my app?

if so please provide links to pages and documentations!

Thank you

2
  • is your question on accessing user from the data provided by contacts? or a friend requesting algorithm? Commented Sep 19, 2020 at 5:22
  • A friend Request algorithm Commented Sep 19, 2020 at 5:37

1 Answer 1

3

There are lots of ways this could be achieved, one is creating a collection Users and each document per user, inside that user document you will have two Lists of user ids 1. friends 2. requests ... so when someone sends a request, add the sender's user-id into requests section inside the receiver's user document, when the user accepts the request delete the user id from the requests and add sender's user-id into friends list.

Root => Users(collection) => userid1(document) => friends(List<String>) => requests(List<String>) 

This is just one way do your research and use what's appropriate for you. :)

Sign up to request clarification or add additional context in comments.

2 Comments

glad it helped, you can refer this on how to add the item to a list inside a document, and if you want to query all the user's sent requests you can use arrayContains. these are just a hint I highly recommend to refer the documentations.
again thanks a lot mate

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.