@napacitor/contacts
Contacts plugin: read all contacts on the device and open the system contact picker. Wraps the .NET MAUI Contacts API.
Installation
To use npm:
npm install @napacitor/contacts
To use yarn:
yarn add @napacitor/contacts
Sync native files:
npx nap sync
Usage
import { Contacts } from '@napacitor/contacts';
// ── Read all contacts ────────────────────────────────────
const contacts = await Contacts.getContacts();
for (const contact of contacts) {
console.log(contact.displayName, contact.phones, contact.emails);
}
// ── System contact picker (returns null on cancel) ────────
const picked = await Contacts.pickContact();
if (picked) {
console.log(picked.id, picked.displayName);
console.log(picked.phones.map((p) => p.phoneNumber));
console.log(picked.emails.map((e) => e.emailAddress));
}
How It Works
Wraps the .NET MAUI Contacts.Default facade: getContacts() calls GetAllAsync() to read all contacts on the device (its cancellationToken parameter is not supported on Android); pickContact() calls PickContactAsync() on the UI thread to present the system contact dialog (null on cancel). On the C# side, the Contacts type is fully qualified with the Communication alias as required by the official docs (to avoid a namespace conflict on iOS/macOS); the Emails / Phones collections of Contact are mapped one by one into result DTOs.
Permissions
Android
Declare the READ_CONTACTS permission in Platforms/Android/AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_CONTACTS" />
Alternatively, declare it in Platforms/Android/MainApplication.cs with the [assembly: UsesPermission(Android.Manifest.Permission.ReadContacts)] assembly attribute.
iOS
No additional configuration required by the official docs. Note: when calling getContacts() to read the contact store, the system may require the app to declare NSContactsUsageDescription in Info.plist (the reason shown to the user when requesting access), otherwise the call fails.
Windows
Per the official docs, picking a contact is not supported; pickContact() throws UNSUPPORTED.
API
getContacts()
Gets all contacts on the device (throws when permission is denied).
Returns: Promise<ContactInfo[]>
pickContact()
Opens the system contact picker to select a single contact; returns null when the user cancels (not supported on Windows, throws UNSUPPORTED).
Returns: Promise<ContactInfo | null>
Interfaces
ContactInfo
| Prop | Type | Description |
|---|---|---|
id | string | Contact ID. |
displayName | string | Display name (inferred from the name when not set). |
namePrefix | string | Name prefix (e.g. 'Dr.'). |
givenName | string | Given name. |
middleName | string | Middle name. |
familyName | string | Family name. |
nameSuffix | string | Name suffix (e.g. 'Jr.'). |
emails | ContactEmail[] | List of email addresses. |
phones | ContactPhone[] | List of phone numbers. |
ContactEmail
| Prop | Type | Description |
|---|---|---|
emailAddress | string | Email address. |
ContactPhone
| Prop | Type | Description |
|---|---|---|
phoneNumber | string | Phone number. |