更新时间:2023-12-03 18:03:10
Follow the steps mentioned in the documentation of react-native-contacts, and add a catch block at the end, it worked for me.
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'This app would like to view your contacts.'
}
).then(() => {
con.getAll((err, contacts) => {
if (err === 'denied'){
// error
} else {
// contacts returned in Array
console.log(contacts);
}
})
})
.catch((err)=> {
console.log(err);
})