Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-contacts
bunx cap sync
import { CapacitorContacts } from '@capgo/capacitor-contacts';

Count the total number of contacts on the device.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.countContacts();

Create a new contact programmatically.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.createContact({} as CreateContactOptions);

Create a new contact group.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.createGroup({} as CreateGroupOptions);

Delete a contact by ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({} as DeleteContactByIdOptions);

Delete a group by ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({} as DeleteGroupByIdOptions);

Display a contact using the native contact viewer.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({} as DisplayContactByIdOptions);

Display the native create contact UI.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayCreateContact();

Display the native update contact UI for a specific contact.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({} as DisplayUpdateContactByIdOptions);

Get all accounts available on the device.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.getAccounts();

Get a specific contact by ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.getContactById({} as GetContactByIdOptions);

Get all contacts from the device.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.getContacts();

Get a specific group by ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.getGroupById({} as GetGroupByIdOptions);

Get all contact groups.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.getGroups();

Check if contacts are available on the device.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.isAvailable();

Check if the plugin is supported on the current platform.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.isSupported();

Open the device’s contacts settings.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.openSettings();

Pick a single contact using the native contact picker.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.pickContact();

Pick one or more contacts using the native contact picker.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.pickContacts();

Update an existing contact by ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({} as UpdateContactByIdOptions);

Check the current permission status for contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.checkPermissions();

Request permissions to access contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.requestPermissions();

Result from counting contacts.

export interface CountContactsResult {
/**
* Total number of contacts.
*
* @since 1.0.0
*/
count: number;
}

Options for creating a contact.

export interface CreateContactOptions {
/**
* Contact information to create. The 'id' field will be generated automatically.
*
* @since 1.0.0
*/
contact: Omit<Contact, 'id'>;
}

Result from creating a contact.

export interface CreateContactResult {
/**
* The ID of the newly created contact.
*
* @since 1.0.0
*/
id: string;
}

Options for creating a group.

export interface CreateGroupOptions {
/**
* Group information to create. The 'id' field will be generated automatically.
*
* @since 1.0.0
*/
group: Omit<Group, 'id'>;
}

Result from creating a group.

export interface CreateGroupResult {
/**
* The ID of the newly created group.
*
* @since 1.0.0
*/
id: string;
}

Options for deleting a contact by ID.

export interface DeleteContactByIdOptions {
/**
* The ID of the contact to delete.
*
* @since 1.0.0
*/
id: string;
}

Options for deleting a group by ID.

export interface DeleteGroupByIdOptions {
/**
* The ID of the group to delete.
*
* @since 1.0.0
*/
id: string;
}

Options for displaying a contact by ID.

export interface DisplayContactByIdOptions {
/**
* The ID of the contact to display.
*
* @since 1.0.0
*/
id: string;
}

Options for displaying the native create contact UI.

export interface DisplayCreateContactOptions {
/**
* Optional pre-filled contact information for the create UI.
*
* @since 1.0.0
*/
contact?: Omit<Contact, 'id'>;
}

Result from displaying the native create contact UI.

export interface DisplayCreateContactResult {
/**
* The ID of the created contact, if one was created. Undefined if the user cancelled.
*
* @since 1.0.0
*/
id?: string;
}

Options for displaying the native update contact UI.

export interface DisplayUpdateContactByIdOptions {
/**
* The ID of the contact to update.
*
* @since 1.0.0
*/
id: string;
}

Result from getting accounts.

export interface GetAccountsResult {
/**
* List of accounts available on the device.
*
* @since 1.0.0
*/
accounts: Account[];
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

If you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-contacts for the native capability in Using @capgo/capacitor-contacts, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.