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
Always provide fallback behavior for browsers and platforms that don't support the Contact Picker API. The component will dispatch an unavailable event when the API is not available.
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
selectOpens the native contact picker dialog.
Options:
multiple(boolean, optional): Iftrue, allows selecting multiple contacts. Default:false
Example for single contact:
Example for multiple contacts:
Targets
None
Events
pwa--contact-picker:selection
pwa--contact-picker:selectionDispatched 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 addressestel(string[]|null): Array of phone numbersaddress(string[]|null): Array of physical addressesicon(Blob|null): Contact's photo/avatar as a Blob (if available and supported)
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
pwa--contact-picker:errorDispatched 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
pwa--contact-picker:unavailableDispatched when the Contact Picker API is not available on the current browser/platform.
No payload
Example:
Best Practices
Always provide fallback: Not all platforms support Contact Picker - provide manual input
Handle empty data: Contact properties can be null or empty - always check before using
Request only what you need: The API provides basic contact info, not full contact details
Respect user privacy: Only use selected contact data for its intended purpose
Clear selection state: Allow users to modify or remove selected contacts
Validate input: Don't assume contact data is valid (emails might be malformed, etc.)
Handle cancellation gracefully: Users might cancel the picker - don't treat as error
Test on real devices: Contact Picker behavior varies between devices
Use progressive enhancement: Build core functionality without Contact Picker first
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
Chrome/Edge (Android)
✓ Full support
Chrome/Edge (Desktop)
✗ Not supported
Safari (iOS)
✗ Not supported
Safari (Desktop)
✗ Not supported
Firefox
✗ Not supported
Due to extremely limited platform support, the Contact Picker API should be treated as a progressive enhancement. Always provide alternative ways to input contact information.
Last updated
Was this helpful?