スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-persistent-uuid`
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/persistent-uuid/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アシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いの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-uuidbunx cap syncクイックスタート
「クイックスタート」セクションimport { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const result = await PersistentUuid.getId();console.log(result);例: resetId
「例: resetId」というタイトルのセクションimport { PersistentUuid } from '@capgo/capacitor-persistent-uuid';
const result = await PersistentUuid.resetId();console.log(result);よくある落とし穴
「よくある落とし穴」セクション- ネイティブ同期: 実行
bunx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
インポート
「インポート」セクション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が作成・保存されます。以降の呼び出しでは、同じスコープに対して同じUUIDが返されます。
安定したカスタムスコープの使用
「安定したカスタムスコープを使用する」セクションネイティブのデフォルトスコープは、Androidではパッケージ名、iOSではバンドル識別子です。デバッグ用と本番用のビルドでパッケージ識別子が異なるものの、同じUUIDを共有する必要がある場合は、共通のスコープを指定してください。
const result = await PersistentUuid.getId({ scope: 'com.example.app',});UUIDのリセット
「UUIDのリセット」セクションユーザーのログアウト時、プライバシーのリセット要求時、または自動テストで新しい識別子が必要な場合に resetId を呼び出してください。
const replacement = await PersistentUuid.resetId();console.log(replacement.id);永続性の仕様
「永続性の仕様」セクション- Androidでは、パッケージ名またはカスタムスコープが安定していれば、署名キーが異なるAndroid StudioやPlay Store経由のインストールであっても、アンインストールと再インストールをまたいで保持されます。
- iOSでは、Keychainのアクセスルールが維持されている限り、アプリのアップデートやiOSのアップデート後も保持されます。
- Webでは localStorage を使用するため、開発時のフォールバックとしてのみ機能します。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド アプリに永続的な識別子を追加するには、以下と連携してください: @capgo/capacitor-persistent-uuid 概要についてはこちら、 Androidでの動作 再インストール時の挙動についてはこちら、 iOSの挙動 Keychainの挙動についてはこちら。 @capgo/capacitor-persistent-uuid を使用する チュートリアルについては、 Capgo プラグインディレクトリ 他のNative Pluginの場合も同様です。