Manzoor Samad
Manzoor Samad

Reputation: 929

How to access contact list in react native app

I am developing a complete mobile CRM, as part of the development I need to access and modify contact list over the phone.

Which is the best plugin to use for this purpose?

Upvotes: 11

Views: 29316

Answers (4)

Irshad Babar
Irshad Babar

Reputation: 1419

Now, They have api that return contacts based on provided phone number, here is an example

import Contacts from 'react-native-contacts';

  const phoneNumber = "+92123456789"; //Number could be complete and it will search 
                                      //with all the numbers from the contacts 
                                      //database and will return results accordingly. 

  Contacts.getContactsByPhoneNumber(phoneNumber, (err, contacts) => {
    if (err) {
      console.log('some error happended ' + err);
    } else {
      // contact is javascript object and that can have more that one contacts details
      console.log('Contact : ' + JSON.stringify(contacts));
    }
  });

further details can be get from here https://www.npmjs.com/package/react-native-contacts#api

Upvotes: 0

webjaros
webjaros

Reputation: 304

If you're using expo, then you'd better use expo-contacts. I've found it really easy to use.

Upvotes: 2

Ashwani Panwar
Ashwani Panwar

Reputation: 4578

First you need to install react-native-contacts library. Run this command npm install react-native-contacts --save .

Then use this code

import Contacts from 'react-native-contacts';

Contacts.getAll((err, contacts) => {
  if (err) {
    throw err;
  }
 // contacts returned
})

For specific access on IOS and android go through this link React native contacts

Upvotes: 1

diatrevolo
diatrevolo

Reputation: 2822

Look at React Native Contacts, found here

Upvotes: 13

Related Questions