Detect if contact's phone is registered in firebase

Viewed 97

I have a question about React Native / Firebase.

I am in the process of developing an app with a contact list retrieved from the phone. I would like from the phone contacts to detect if the phone number exists as a user in my firebase database.

Like WhatsApp which lists the people who have a whatsapp account in the user's phone.

The biggest problem is having a minimal number of firebase requests, so as not to make 200 requests (if the phone has 200 contacts) by phone when you open your contacts.

Could you guide me? Thank you

1 Answers

I would recommend making the request in one query. For example in SQL it would be similar to;

SELECT phone FROM phone_table WHERE phone IN ('phone1', 'phone2');

To optimise the process further you can try the following;

  • Reduce the searchable dataset by saving the phones in your database with a country_code field, then splitting the users contacts into different country codes (on average most users numbers are usually majority from the same country/countries) and run the SELECT query on a numbers from a specific country.
  • Store the existing matches you find in AsyncStorage so you can reduce the values the select query has to run the next time.
Related