スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-uwb`
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/uwb/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-uwb` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-uwbbunx cap syncインポート
「インポート」セクションimport { CapacitorUwb } from '@capgo/capacitor-uwb';クイックスタート
「クイックスタート」セクションimport { CapacitorUwb } from '@capgo/capacitor-uwb';
const result = await CapacitorUwb.isAvailable();console.log(result);例: getDiscoveryToken
「例: getDiscoveryToken」というセクションimport { CapacitorUwb } from '@capgo/capacitor-uwb';
const result = await CapacitorUwb.getDiscoveryToken();// The result holds sensitive values: use it without logging it.例: startPeerSession
「例: startPeerSession」というセクションimport { CapacitorUwb } from '@capgo/capacitor-uwb';
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: 'peer-discovery-token-123' });よくある落とし穴
「よくある落とし穴」セクション- リスナー: 画面がアンマウントされたらハンドルを削除します。
- ネイティブ同期: 実行
bunx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
利用可能性の確認
「利用可能性の確認」というセクションconst availability = await CapacitorUwb.isAvailable();
if (!availability.supported) { console.log('This device does not support UWB.');}iOS Peer Session
「iOS Peer Session」というセクション- 呼び出す
getDiscoveryToken()両方のデバイスで。 - 返されたbase64トークンを、別の手段(out-of-band)で交換してください。
- ピアトークンを使用してレンジングを開始します。
const { discoveryToken } = await CapacitorUwb.getDiscoveryToken();
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: '<peer-token-base64>',});詳細は iOSの設定 機能および権限の要件について。
Android Controller / Controlee セッション
「Android Controller / Controlee セッション」というセクション- コントローラーが呼び出し、
startControllerSession()返されたデータを共有します。rangingParametersとlocalAddress. - Controlee は独自のデータを構築し、
rangingParametersコントローラーを使用して、localAddressとしてpeerAddress. - Controleeからの呼び出し
startControleeSession({ rangingParameters }). - オプションで以下を渡します
peerAddressControleeのアドレスが判明次第、controllerに渡します。
const controller = await CapacitorUwb.startControllerSession();
await CapacitorUwb.startControleeSession({ rangingParameters: { ...controller.rangingParameters, peerAddress: controller.localAddress, },});詳細は Androidの設定 ハードウェアおよび権限の要件についてはこちら。
アップデートの待機
「アップデートの待機」セクションawait CapacitorUwb.addListener('rangingUpdate', (event) => { console.log(event.distanceMeters, event.direction);});
await CapacitorUwb.addListener('sessionStateChanged', (event) => { console.log(event.state, event.reason);});セッションの停止
「Stop The Session」セクションawait CapacitorUwb.stopSession();Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.ts. TypeScriptの定義を更新して実行してください: bun run docgen プラグインのリポジトリ内で実行することで、生成された API ドキュメントが最新の状態になります。