I have a contact component that works as expected, but if a user initially denies the request to grant my app access to their contact the request is not being asked again, the contact modal instead appears empty:
useEffect(() => {
(async () => {
const { status } = await Contacts.requestPermissionsAsync()
if (status === "granted") {
const { data } = await Contacts.getContactsAsync({
fields: [Contacts?.Fields?.PhoneNumbers],
});
if (data.length > 0) {
setContacts(data);
}
}
})();
}, []);
2
Answers
I had to install expo-linking using
npx expo install expo-linking
Check
canAskAgain
if the permission can be requested, if not give a user option to open Settings.