Get contacts from phone using react native expo I'm not getting it
Use Contacts and Permissions, get user permission and then take the data as stated in the Expo docs. Here is an example: Snack Contact Example
async showFirstContactAsync() {
// Ask for permission to query contacts.
const permission = await Permissions.askAsync(Permissions.CONTACTS);
if (permission.status !== 'granted') {
// Permission was denied...
return;
}
const contacts = await Contacts.getContactsAsync({
fields: [
Contacts.PHONE_NUMBERS,
Contacts.EMAILS,
],
pageSize: 10,
pageOffset: 0,
});
if (contacts.total > 0) {
Alert.alert(
'Your first contact is...',
`Name: ${contacts.data[0].name}\n` +
`Phone numbers: ${contacts.data[0].phoneNumbers[0].number}\n` +
`Emails: ${contacts.data[0].emails[0].email}`
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With