Contact Picker API - patrickcole/learning GitHub Wiki
Contact Picker API
- Provides the ability to access user's contacts for use in web applications
- Will only work on secure (
https
) domain
Check for Availability
const supportsContacts = ('contacts' in navigator && 'ContactsManager' in window);
Access Contacts
- Done via a
Promise
, being that the task is asynchronous
- Can be done via
async/await
if prefer using that pattern
navigator.contacts.select(["name", "tel"])
.then(contacts => console.log(contacts))
.catch(console.error);
// => [{ "name": ["Phil Nash"], "tel": ["+61412345678", "+447123456789"]}]
Sources