How to use the expo-contacts.getContactsAsync function in expo-contacts

To help you get started, we’ve selected a few expo-contacts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / native-component-list / src / screens / Contacts / ContactUtils.ts View on Github external
export async function removeAllChildrenFromGroupWithNameAsync(groupName: string) {
  try {
    const groupId = await ensureGroupAsync(groupName);

    const { data: contacts } = await Contacts.getContactsAsync({ groupId });
    await Promise.all(
      contacts.map(contact => Contacts.removeContactFromGroupAsync(contact.id, groupId!))
    );
  } catch ({ message }) {
    // tslint:disable-next-line no-console
    console.error(message);
  }
}
github celo-org / celo-monorepo / packages / dappkit / src / index.ts View on Github external
export async function fetchContacts(
  kit: ContractKit
): Promise<{ rawContacts: ContactsById; phoneNumbersByAddress: PhoneNumberMappingEntryByAddress }> {
  const contacts = await getContactsAsync({
    fields: [Fields.PhoneNumbers, Fields.Image],
  })

  const filteredContacts = contacts.data.filter((contact) => {
    return (
      contact.phoneNumbers && find(contact.phoneNumbers, (p) => isValidPhoneNumber(p) !== undefined)
    )
  })

  const rawContacts = fromPairs(filteredContacts.map((contact) => [contact.id, contact]))

  // @ts-ignore
  const phoneNumbersToContacts = createPhoneNumberToContactMapping(filteredContacts)

  const phoneNumbersByAddress = await lookupPhoneNumbersOnAttestations(kit, phoneNumbersToContacts)
github expo / expo / apps / native-component-list / src / screens / Contacts / ContactUtils.ts View on Github external
export async function debugAddFirstContactToGroupAsync() {
  const groupId = await ensureGroupAsync('Expo Contacts');
  const { data: contacts } = await Contacts.getContactsAsync({ pageSize: 1 });
  const contact = contacts[0];
  Contacts.addExistingContactToGroupAsync(contact.id, groupId!);
}
github syousif94 / frugalmaps / buncha / utils / Contacts.js View on Github external
export async function getContacts() {
  const { status } = await Permissions.askAsync(Permissions.CONTACTS);
  if (status !== "granted") {
    return [];
  }

  const { data } = await Contacts.getContactsAsync({
    fields: [Contacts.Fields.Name, Contacts.Fields.PhoneNumbers]
  });

  if (!data.length) {
    return [];
  }

  const contacts = data
    .reduce((contacts, item) => {
      const hasUSNumber =
        item.phoneNumbers &&
        item.phoneNumbers.length &&
        item.phoneNumbers[0] &&
        item.phoneNumbers[0].countryCode === "us";

      if (hasUSNumber) {