I am following this blog to set up react-native-contacts. After following the steps when I try to get all contacts
Contacts.getAll().then((contacts) => {
console.log(contacts)
})
I get this error.
TypeError: Cannot read property 'getAll' of null
For some reason importing Contacts from react-native-contacts appears to be null?
I am not sure if there is an issue with my set up. I followed up by reading over react-natives-contacts set up instructions.
- Set up the correct permissions for android and iOS (currently testing on iOS simulator)
- Android:
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'This app would like to view your contacts.',
'buttonPositive': 'Please accept bare mortal'
}
)
.then(Contacts.getAll()
.then((contacts) => {
// work with contacts
console.log(contacts)
})
.catch((e) => {
console.log(e)
}))
-----------------------------
// in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_CONTACTS" />
- iOS:
- Added "Privacy - Contacts Usage Description" key to info.plist
I am using RN 0.69 so auto linking should be enabled? not sure what am I missing?