본문 바로가기

시작하기

GitHub

AI 지원 설정으로 플러그인을 설치할 수 있습니다. 다음 명령어로 AI 도구에 Capgo 스킬을 추가하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

그다음 아래 prompt를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-contacts` plugin in my project.

Manual Setup을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
npm install @capgo/capacitor-contacts
npx cap sync
import { CapacitorContacts } from '@capgo/capacitor-contacts';

접근 권한을 요청한 다음, 전체 주소록을 불러오는 대신 적절한 페이지 크기로 연락처를 로드하세요.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.requestPermissions();
const { contacts } = await CapacitorContacts.getContacts({ limit: 50, offset: 0 });
// Increase offset by limit for the next page instead of loading the full address book.
  • 개요: 다이얼로그가 나타나기 전 연락처 권한이 필요한 이유를 설명합니다.
  • 페이지네이션: 주소록 전체를 한 번에 로드하는 것을 방지합니다.
  • 쓰기 권한: 연락처를 생성하려면 쓰기 권한이 필요합니다.

기기에 저장된 전체 연락처 수를 계산합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();
console.log(result);

프로그램 방식으로 새 연락처를 생성합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });
console.log(result);

새 연락처 그룹을 생성합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });
console.log(result);

ID를 사용하여 연락처를 삭제합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });

ID를 사용하여 그룹을 삭제합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });

네이티브 연락처 뷰어를 사용하여 연락처를 표시합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });

네이티브 연락처 생성 UI를 표시합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.displayCreateContact();
console.log(result);

특정 연락처에 대한 네이티브 연락처 업데이트 UI를 표시합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({ id: 'id-123' });

기기에서 사용 가능한 모든 계정을 가져옵니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getAccounts();
console.log(result);

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.

기기의 모든 연락처를 가져옵니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContacts();
// The result holds sensitive values: use it without logging it.

ID로 특정 그룹을 가져옵니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroupById({ id: 'id-123' });
console.log(result);

모든 연락처 그룹을 가져옵니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroups();
console.log(result);

기기에서 연락처를 사용할 수 있는지 확인합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isAvailable();
console.log(result);

현재 플랫폼에서 플러그인을 지원하는지 확인합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isSupported();
console.log(result);

기기의 연락처 설정 화면을 엽니다.

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

네이티브 연락처 선택기로 연락처 하나를 선택합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContact();
// The result holds sensitive values: use it without logging it.

네이티브 연락처 선택기로 하나 이상의 연락처를 선택합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContacts();
// The result holds sensitive values: use it without logging it.

ID로 기존 연락처를 업데이트합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({
id: 'id-123',
contact: {},
});

연락처 권한 상태를 확인합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.checkPermissions();
console.log(result);

연락처 접근 권한을 요청합니다.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.requestPermissions();
console.log(result);

연락처 개수 확인 결과입니다.

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

연락처 생성을 위한 옵션입니다.

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

연락처 생성 결과입니다.

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

그룹 생성 옵션입니다.

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

그룹 생성 결과입니다.

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

ID로 연락처를 삭제하기 위한 옵션입니다.

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

ID로 그룹을 삭제하기 위한 옵션입니다.

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

ID로 연락처를 표시하기 위한 옵션입니다.

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

DisplayCreateContactOptions

“DisplayCreateContactOptions” 섹션

네이티브 연락처 생성 UI를 표시하기 위한 옵션입니다.

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

DisplayCreateContactResult

“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

“DisplayUpdateContactByIdOptions” 섹션

네이티브 연락처 수정 UI를 표시하기 위한 옵션입니다.

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

계정 목록 조회 결과입니다.

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

이 페이지는 플러그인의 src/definitions.ts에서 생성되었습니다. public API가 업스트림에서 변경되면 동기화를 다시 실행하세요.

사용 중인 경우 시작하기 대시보드와 API 운영을 계획하려면, 이를 다음 항목과 연결하세요: @capgo/capacitor-contacts 사용하기 @capgo/capacitor-contacts를 사용하여 네이티브 기능을 구현하려면, API 개요 API Overview의 구현 상세 내용은 소개 Introduction의 구현 상세 내용은 API 키 API Keys의 구현 세부 사항은, 디바이스 Devices의 구현 세부 사항은.