ContactsManager: getProperties() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The getProperties() method of the ContactsManager interface returns a Promise which resolves with an Array of strings indicating which contact properties are available.

Syntax

js
getProperties()

Parameters

None.

Return value

Returns a Promise that resolves with an Array of strings naming the contact properties that can be returned by the current system.

Properties can include the following:

  • 'name': The contact's name.
  • 'tel': The telephone number(s) of the contact.
  • 'email': The email address of the contact.
  • 'address': The contact's postal address.
  • 'icon': The avatar of the contact.

Exceptions

No exceptions are thrown.

Examples

Verify Property Support

The following asynchronous function uses the getProperties() method to check whether the current system supports the icon property.

js
async function checkProperties() {
  const supportedProperties = await navigator.contacts.getProperties();
  if (!supportedProperties.includes("icon")) {
    console.log("Your system does not support getting icons.");
  }
}

Select Using Only Supported Properties

The following example is similar to one for the select() method. Instead of hard-coding the properties passed to select(), it uses getProperties() to ensure that only supported properties are passed. Otherwise, select() might throw a TypeError. handleResults() is a developer defined function.

js
const supportedProperties = await navigator.contacts.getProperties();

async function getContacts() {
  try {
    const contacts = await navigator.contacts.select(supportedProperties);
    handleResults(contacts);
  } catch (ex) {
    // Handle any errors here.
  }
}

Specifications

Specification
Contact Picker API
# contacts-manager-getproperties

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getProperties
Experimental
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote
footnote See bug 1756767
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 80 (Release date: 2020-02-04)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote See bug 1756767
Opera Android – Full support
Opera Android 57 (Release date: 2020-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS 14.5 (Release date: 2021-04-26)
disabled
disabled From version 14.5 users must explicitly set the Contact Picker API preference.
Samsung Internet – Partial support
Samsung Internet 14 – 21 (Release date: 2021-04-17)
footnote Removed in 22 and later
footnote Partial support
footnote This API was exposed but failed upon opening a contact selector.
WebView Android – Full support
WebView Android 80 (Release date: 2020-02-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.