I have already tried to solve this problem using
react-native-contacts getAll return null, react-native-contacts returns undefined.
But, unfortunately, I can't get success. I've already run below shells:
npm install react-native-contacts --save
react-native link react-native-contacts
Here is my code =========
import Contacts from 'react-native-contacts';
componentDidMount() {
if(Platform.OS === 'ios'){
Contacts.getAll((err, contacts) => {
if (err) {
throw err;
}
// contacts returned
console.log("contacts => ", contacts);
})
}else if(Platform.OS === 'android'){
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
title: 'Contacts',
message: 'This app would like to view your contacts.'
}
).then(() => {
Contacts.getAll((err, contacts) => {
if (err === 'denied'){
// error
} else {
// contacts returned in Array
console.log("contacts => ", contacts);
}
})
})
}
}
====================================== Here is my result.
screen shoot my error terminal
My environment :
> expo --version
> 4.0.6
> node --version
> v14.15.0
> npm --version
> 6.14.8