开始
复制一个包含安装步骤和本插件完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-contacts`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/contacts/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
您可以使用我们的AI辅助设置来安装插件。将Capgo技能添加到您的AI工具中,使用以下命令:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-contacts` plugin in my project.如果您prefer手动设置,安装插件并运行以下命令并遵循以下平台特定的说明:
bun add @capgo/capacitor-contactsbunx cap syncimport { CapacitorContacts } from '@capgo/capacitor-contacts';API 简介
API OverviewcountContacts
countContacts统计设备上的联系人总数
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();console.log(result);createContact
createContact创建联系人
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });console.log(result);createGroup
createGroup创建联系人组
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });console.log(result);deleteContactById
deleteContactById通过 ID 删除联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });deleteGroupById
标题:删除组通过 ID 删除组。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });displayContactById
标题:显示联系人使用原生联系人查看器显示联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });displayCreateContact
标题:显示创建联系人显示原生创建联系人界面。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.displayCreateContact();console.log(result);displayUpdateContactById
标题:显示更新联系人显示特定联系人的本地更新联系人界面。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({ id: 'id-123' });getAccounts
获取账户获取设备上的所有可用账户。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getAccounts();console.log(result);getContactById
获取联系人通过 ID 获取特定联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContactById({ id: 'id-123' });// The result holds sensitive values: use it without logging it.getContacts
获取设备上的所有联系人。获取群组
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContacts();// The result holds sensitive values: use it without logging it.getGroupById
通过 ID 获取特定群组。通过 ID 获取特定组。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroupById({ id: 'id-123' });console.log(result);getGroups
获取联系人组获取所有联系人组。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroups();console.log(result);isAvailable
联系人是否可用检查设备上联系人是否可用。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isAvailable();console.log(result);isSupported
检查插件是否支持当前平台。打开设置
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isSupported();console.log(result);openSettings
检查插件是否支持当前平台。打开设备的联系人设置。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.openSettings();pickContact
标题:选择联系人使用原生联系人选择器选择一个联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContact();// The result holds sensitive values: use it without logging it.pickContacts
标题:选择联系人使用原生联系人选择器选择一个或多个联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContacts();// The result holds sensitive values: use it without logging it.updateContactById
标题:更新联系人通过 ID 更新一个现有的联系人。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({ id: 'id-123', contact: {},});checkPermissions
标题:检查权限检查联系人当前的权限状态。
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.checkPermissions();console.log(result);requestPermissions
请求权限请求联系人权限
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.requestPermissions();console.log(result);类型参考
类型参考CountContactsResult
联系人计数结果创建联系人选项
export interface CountContactsResult { /** * Total number of contacts. * * @since 1.0.0 */ count: number;}CreateContactOptions
联系人计数结果创建联系人选项
export interface CreateContactOptions { /** * Contact information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ contact: Omit<Contact, 'id'>;}CreateContactResult
标题:创建联系人结果创建联系人后的结果。
export interface CreateContactResult { /** * The ID of the newly created contact. * * @since 1.0.0 */ id: string;}CreateGroupOptions
标题:创建群组选项创建群组的选项。
export interface CreateGroupOptions { /** * Group information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ group: Omit<Group, 'id'>;}CreateGroupResult
标题:创建群组结果创建群组后的结果。
export interface CreateGroupResult { /** * The ID of the newly created group. * * @since 1.0.0 */ id: string;}DeleteContactByIdOptions
标题:删除联系人ID选项删除联系人ID的选项。
export interface DeleteContactByIdOptions { /** * The ID of the contact to delete. * * @since 1.0.0 */ id: string;}DeleteGroupByIdOptions
标题:删除组件删除组件的选项。
export interface DeleteGroupByIdOptions { /** * The ID of the group to delete. * * @since 1.0.0 */ id: string;}DisplayContactByIdOptions
标题:显示联系人显示联系人ID的选项。
export interface DisplayContactByIdOptions { /** * The ID of the contact to display. * * @since 1.0.0 */ id: string;}DisplayCreateContactOptions
标题:显示创建联系人显示原生创建联系人UI的选项。
export interface DisplayCreateContactOptions { /** * Optional pre-filled contact information for the create UI. * * @since 1.0.0 */ contact?: Omit<Contact, 'id'>;}DisplayCreateContactResult
标题:显示创建联系人结果显示原生创建联系人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;}DisplayUpdateContactByIdOptions
标题:显示更新联系人选项显示原生更新联系人 UI 的选项。
export interface DisplayUpdateContactByIdOptions { /** * The ID of the contact to update. * * @since 1.0.0 */ id: string;}GetAccountsResult
标题:获取账户结果获取账户的结果。
export interface GetAccountsResult { /** * List of accounts available on the device. * * @since 1.0.0 */ accounts: Account[];}真实数据来源
标题:真实数据来源本页面由插件生成。重新同步公共__CAPGO_KEEP_0__时,重新运行上游的同步。 src/definitions.ts重新同步时,重新运行公共API的上游变更。
如果您正在使用 开始使用 来规划仪表板和API操作,连接它与 使用@capgo/capacitor-contacts 为native能力在使用@capgo/capacitor-contacts中 API概述 为API概述中的实现细节 介绍 为介绍中的实现细节 API密钥 为API密钥中的实现细节 设备 了解设备的具体实现细节。