I want to make a screen page that can be navigated in the contact list on my phone. so I made a native module for get contact, It worked but for android 10 and below. For android 11 he can't run. The function I created can't get contact data.I've made sure all the permissions are there. Below is the code I made
const getChooseContact = () => {
const { ContactsWrapper } = NativeModules;
ContactsWrapper.getContact()
.then((contact) => {
setPhoneNumber(contact.phoneNumber);
})
.catch((error) => {
console.log(error);
});
};
const requestMediaPermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
getChooseContact();
} else {
setErrorMessage('Access media permission denied');
}
} catch (err) {
console.log(err);
}
};