Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able of browsing phone contact list when creating a new person #30

Open
Doreapp opened this issue Dec 23, 2022 · 2 comments · May be fixed by #34
Open

Be able of browsing phone contact list when creating a new person #30

Doreapp opened this issue Dec 23, 2022 · 2 comments · May be fixed by #34
Assignees

Comments

@Doreapp
Copy link
Owner

Doreapp commented Dec 23, 2022

When creating a new person, be able of opening the contact list of the phone (device) and selecting a contact. This contact would be imported as a new person (filling the fields of the New person form), including the phone number field.

It may look like:

function ContactPickerButton() {
  const [selectedContact, setSelectedContact] = useState(null);

  const handleClick = () => {
    navigator.contacts.pickContact((contact) => {
      setSelectedContact(contact);
    });
  };

  return (
    <div>
      <button onClick={handleClick}>
        Select a contact
      </button>
      {selectedContact && (
        <div>
          <p>Name: {selectedContact.displayName}</p>
          <p>Phone number: {selectedContact.phoneNumbers[0].value}</p>
        </div>
      )}
    <div/>
  );
}
@Doreapp Doreapp self-assigned this Dec 28, 2022
@Doreapp
Copy link
Owner Author

Doreapp commented Dec 28, 2022

According to the documentation firefox android doesn't supports navigator.contacts API. In addition, for an unknown reason yet, I am unable to get

const supported = ('contacts' in navigator && 'ContactsManager' in window);

to be true event when using Chrome, while the demo works perfectly.

Thus, this issue will be in standby for now.

@Doreapp Doreapp removed their assignment Dec 28, 2022
@Doreapp Doreapp self-assigned this Jan 7, 2023
@Doreapp
Copy link
Owner Author

Doreapp commented Jan 7, 2023

Let's reopen this issue, as chrome also allows install as app functionality and the picking works as soon as the website is served using HTTPS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant