Reputation: 929
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
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
Reputation: 304
If you're using expo, then you'd better use expo-contacts. I've found it really easy to use.
Upvotes: 2
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