使用 react native expo 从电话中获取联系人我没有得到它
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}`
);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.