Hello everyone! And congratulations to the Expo Team for the improvements of version 30.0 that I just switched to. The Contacts API is more complete, good job!
However, I am experiencing some issues when querying the contacts with getContactsAsync:
I am querying for contacts with certain fields (PhoneNumbers, Name) but my query parameters are not taken into consideration: some contacts without names or phone numbers are returned.
Find my code below:
import { Contacts } from "expo"
[...]
const ctx = this;
Expo.Permissions.askAsync(Expo.Permissions.CONTACTS)
.then(async permission => {
console.log(permission.status);
if (permission.status !== "granted") {
console.log("permission.status : ", permission.status);
} else {
ctx.setState({ loading: true });
const { data } = await Contacts.getContactsAsync({
fields: [Contacts.Fields.PhoneNumbers, Contacts.Fields.Name],
pageSize: 0,
sort: Contacts.SortTypes.FirstName
});
if (data.length > 0) {
const contact = data[0];
console.log("contact : ", contact);
console.log("data : ", data);
ctx.setState({ loading: false });
})
}
It used to work on v 28.0 with Expo.Contacts.PHONE_NUMBERS
Now that I’ve migrated to v 30.0, it doesn’t and I can’t see if there is an error in my code.
What do you suggest/recommend?
Many thanks!