가이드
Capacitor에서 Persistent UUID 사용법
@capgo/capacitor-persistent-uuid 사용하기
Capacitor용 앱 스코프 Persistent UUID를 하나 생성하고, 일반 앱 스토리지가 제거되는 재설치 및 업데이트 플로우에서도 안정적으로 유지하세요.
설치
npm install @capgo/capacitor-persistent-uuid
npx cap sync
플러그인이 제공하는 기능
- getId - 저장된 UUID를 읽고, 선택한 scope에 없으면 새로 생성합니다.
- resetId - 로그아웃, 개인정보 초기화 또는 테스트 정리 플로우를 위해 저장된 UUID를 회전(Rotate)합니다.
- scope - 디버그와 프로덕션 패키지 식별자가 다른 앱에 선택적으로 사용할 네임스페이스입니다.
사용 예시
import { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const { id, created, scope } = await PersistentUuid.getId();
console.log(id);
console.log(created);
console.log(scope);
빌드 배리언트 간 UUID 공유
const result = await PersistentUuid.getId({
scope: 'com.example.app',
});
console.log(result.id);
식별자 초기화
const replacement = await PersistentUuid.resetId();
console.log(replacement.id);
플랫폼 참고 사항
Android는 AccountManager에 UUID를 저장하여 패키지 이름이나 커스텀 scope가 안정적일 때 Android Studio 재설치 사이클 및 디버그/Play 서명 차이에도 유지됩니다. iOS는 Keychain에 UUID를 저장하여 Keychain 접근이 호환되는 동안 앱 및 iOS 업데이트를 통해 유지됩니다. Web은 개발용 폴백으로 localStorage를 사용합니다.
이 플러그인은 하드웨어 ID를 노출하지 않으며, 공장 초기화, 수동 계정 제거, Keychain 초기화, 브라우저 저장소 초기화 또는 resetId 호출 시 UUID가 유지되지 않습니다.
전체 레퍼런스
- GitHub: https://github.com/Cap-go/capacitor-persistent-uuid/
- 문서: /docs/plugins/persistent-uuid/
계속하기
사용 중이라면 @capgo/capacitor-persistent-uuid 앱 식별자를 안정적으로 유지하려면, 다음 항목과 연결하세요: @capgo/capacitor-persistent-uuid 개요는, 시작하기 설치 및 API 예제 보기, Android 동작 방식 재설치 관련 상세 정보, iOS 동작 Keychain 상세 정보 및 @capgo/capacitor-persistent-account UUID 대신 계정 데이터 지속성이 필요할 때.