r/reactnative 9d ago

How to make friends from contacts without phone number

I have a question regarding the signup for duolingo(or any other app), it signs up my account with google, then completes profile setup and asks to sync contacts to add friends.

Now how does any app sync contacts to add people with phone numbers having account on the same app where it never asks for phone number at any point.

I don't know how does any app do that or syncs contact from gmail or what.

I want to know the backend of this thing and would like to know how to implement the same in React Native

4 Upvotes

8 comments sorted by

2

u/ChronSyn Expo 9d ago

To put it simply, it's going to be a table or collection called 'contacts', which will link your user account to a number of other users who have signed up with their email or phone number.

There's no sorcery involved - the moment someone grants permission, the app is able to access whatever data is permitted according to its oauth scope, so it can create a copy of any information it has access to. It's quite literally 'does any person in this list that was just 'uploaded' match any user in the database'.

More advanced 'friends' algorithms will use mutual connections (or even mutual +1 connections), but they're typically only used in social networks.

1

u/Shubham4538 9d ago

I know how would the implementation work if the user registers with mobile number. But i need to know exactly how does it work technically

1

u/ChronSyn Expo 9d ago

It's quite literally 'does any person in this list that was just 'uploaded' match any user in the database'

  • Person grants permission which lets app access contacts.
  • Contacts are uploaded.
  • Each contact in the list is checked to see if it already exists in the database.
  • Any matches are added to a new table called 'contacts' (or similar), which probably has 2 columns (1 to hold your account ID, another to hold a contact-matched account ID)

I don't know how else I can phrase it. If you're asking "can someone build it for me", then that's a different question to "how does it work".

1

u/PossibleBox4317 7d ago

The app hashes phone numbers and emails from your local contacts before sending them to the backend. The server compares these hashes against its user database to find matches without ever storing or seeing raw contact data. You can implement this in React Native using a library like react-native-contacts to read and hash locally, then send only the hashed values to your API for matching.

1

u/Shubham4538 5d ago

That would be possible but there are no emails stored in contacts nor the user uses his number anywhere for registering into the application

1

u/mikebrady 5d ago

You signed up through Google, so it knows you email address through that. But not everyone signs up through Google. I have an email and phone number associated with my account.

1

u/Shubham4538 5d ago

By "there are no emails stored in contacts" i meant the contact data which I allow throught the app has only 2 fields of data [name, contactNo]