본문 바로가기

시작하기

GitHub

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

터미널 창
bunx 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-persistent-uuid` plugin in my project.

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

터미널 창
bun add @capgo/capacitor-persistent-uuid
bunx cap sync
import { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const result = await PersistentUuid.getId();
console.log(result);
import { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const result = await PersistentUuid.resetId();
console.log(result);

자주 하는 실수

“흔한 실수” 섹션
  • 네이티브 동기화: 실행 bunx cap sync 플러그인 업그레이드 후.
  • 신뢰할 수 있는 소스: 신뢰 src/definitions.ts GitHub 레포지토리에서.
import { PersistentUuid } from '@capgo/capacitor-persistent-uuid';

UUID 읽기 또는 생성하기

“UUID 읽기 또는 생성하기” 섹션
import { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const result = await PersistentUuid.getId();
console.log(result.id);
console.log(result.scope);
console.log(result.created);

첫 호출 시 UUID가 생성 및 저장됩니다. 이후 동일한 scope에 대해 호출하면 저장된 동일한 UUID를 반환합니다.

안정적인 커스텀 scope 사용하기

“안정적인 커스텀 스코프 사용” 섹션

네이티브 기본 스코프는 Android에서는 패키지명, iOS에서는 번들 식별자입니다. 디버그 빌드와 프로덕션 빌드가 서로 다른 패키지 식별자를 사용하지만 하나의 UUID를 공유해야 한다면 공유 스코프를 전달하세요.

const result = await PersistentUuid.getId({
scope: 'com.example.app',
});

사용자가 로그아웃하거나 개인정보 초기화를 요청할 때, 또는 자동화 테스트에 새 식별자가 필요할 때 resetId를 호출하세요.

const replacement = await PersistentUuid.resetId();
console.log(replacement.id);
  • 패키지명이나 커스텀 스코프가 안정적이면 Android는 앱을 삭제하고 재설치해도 UUID가 유지됩니다. 서명 키가 다른 Android Studio와 Play Store 설치도 마찬가지입니다.
  • iOS는 Keychain 접근 규칙이 동일하게 유지되는 한 앱 업데이트와 iOS 업데이트 후에도 UUID가 유지됩니다.
  • 웹은 localStorage를 사용하며, 개발용 폴백일 뿐입니다.

사용 중이라면 시작하기 영구 앱 ID를 추가하려면 다음과 연결하세요: @capgo/capacitor-persistent-uuid 개요는, Android 동작 방식 재설치 동작은, iOS 동작 Keychain 동작은, @capgo/capacitor-persistent-uuid 사용하기 튜토리얼을 위해, 그리고 Capgo 플러그인 디렉토리 다른 native plugin의 경우.