Contact Picker

The Contact Picker component provides access to the Contact Picker API, allowing users to select one or more contacts directly from their device's native address book. This enables seamless integration with the device's contact system while maintaining user privacy through explicit consent for each selection.

This component is particularly useful for:

  • Social applications requiring contact selection for invitations

  • Communication apps for selecting recipients

  • Event management for adding attendees

  • Sharing features that integrate with contacts

  • Forms requiring contact information input

  • CRM applications for importing contacts

  • Messaging platforms for contact-based features

  • Emergency contact selection in forms

  • Group creation and management features

Browser Support

The Contact Picker API is currently only available on Android devices with Chrome/Edge browsers. It's not supported on desktop or iOS platforms.

Supported Platforms:

  • Chrome/Edge on Android: Full support

  • Desktop browsers: Not supported

  • iOS Safari: Not supported

  • Firefox: Not supported

circle-exclamation

Usage

Basic Contact Selection

Multiple Contact Selection

Form Integration

Email Composer

Event Attendees Selector

Contact Import for CRM

Parameters

None - The select action accepts parameters to control the selection behavior.

Actions

select

Opens the native contact picker dialog.

Options:

  • multiple (boolean, optional): If true, allows selecting multiple contacts. Default: false

Example for single contact:

Example for multiple contacts:

Targets

None

Events

pwa--contact-picker:selection

Dispatched when the user successfully selects one or more contacts from the picker.

Payload: {contacts: Array<Contact>}

Each contact object may include:

  • name (string[]|null): Array of name strings (may contain multiple names)

  • email (string[]|null): Array of email addresses

  • tel (string[]|null): Array of phone numbers

  • address (string[]|null): Array of physical addresses

  • icon (Blob|null): Contact's photo/avatar as a Blob (if available and supported)

circle-info

All contact properties are optional and may be null or empty arrays depending on what information is available in the device's contact book.

Example:

pwa--contact-picker:error

Dispatched when an error occurs during contact selection or when the user cancels the picker.

Payload: {exception: Error}

Common causes:

  • User cancelled the picker

  • Permission denied

  • API error

Example:

pwa--contact-picker:unavailable

Dispatched when the Contact Picker API is not available on the current browser/platform.

No payload

Example:

Best Practices

  1. Always provide fallback: Not all platforms support Contact Picker - provide manual input

  2. Handle empty data: Contact properties can be null or empty - always check before using

  3. Request only what you need: The API provides basic contact info, not full contact details

  4. Respect user privacy: Only use selected contact data for its intended purpose

  5. Clear selection state: Allow users to modify or remove selected contacts

  6. Validate input: Don't assume contact data is valid (emails might be malformed, etc.)

  7. Handle cancellation gracefully: Users might cancel the picker - don't treat as error

  8. Test on real devices: Contact Picker behavior varies between devices

  9. Use progressive enhancement: Build core functionality without Contact Picker first

  10. Inform users: Explain why you need contact access and what you'll do with it

Handling Contact Data

Extracting Primary Contact Info

Validating Contact Data

Deduplicating Contacts

Complete Example: Contact Management App

Troubleshooting

API not available

Issue: Contact Picker not working

Platform limitations:

  • Only works on Android with Chrome/Edge

  • Not available on iOS, desktop, or other browsers

Solution: Always provide manual input fallback:

User cancels picker

Issue: Error event fires when user cancels

Cause: Cancellation is treated as an AbortError

Solution: Handle gracefully:

Empty contact data

Issue: Selected contacts have no email/phone

Cause: Not all contacts in device address book have complete information

Solution: Validate and filter:

Icon/photo not loading

Issue: Contact icon property is not available

Cause: Limited support for contact photos

Solution: Use fallback avatars with initials:

Platform Compatibility

Platform
Support

Chrome/Edge (Android)

✓ Full support

Chrome/Edge (Desktop)

✗ Not supported

Safari (iOS)

✗ Not supported

Safari (Desktop)

✗ Not supported

Firefox

✗ Not supported

triangle-exclamation

Last updated

Was this helpful?