スタートガイド
インストール手順と、このプラグインの完全な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
セクション「Example: getDiscoveryToken」import { CapacitorUwb } from '@capgo/capacitor-uwb';
const result = await CapacitorUwb.getDiscoveryToken();// The result holds sensitive values: use it without logging it.例: startPeerSession
セクション「Example: 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ピアセッション
「iOS Peer Session」セクション- 呼び出す
getDiscoveryToken()両方のデバイスで。 - 返された base64 トークンをアウトオブバンドで交換します。
- ピアトークンでレンジングを開始します。
const { discoveryToken } = await CapacitorUwb.getDiscoveryToken();
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: '<peer-token-base64>',});詳細は iOSの設定 ケイパビリティと権限の要件については。
Android コントローラー / コントローリー セッション
セクション「Android Controller / Controlee Session」- コントローラーが
startControllerSession()を呼び出し、返されたrangingParametersとlocalAddress. - を共有します。コントローリーは独自の
rangingParametersを、コントローラーのlocalAddressとしてpeerAddress. - を使って構築します。コントローリーが
startControleeSession({ rangingParameters }). - を呼び出します。任意で
peerAddresscontrolee アドレスが判明したら、コントローラーに送信します。
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);});セッションの停止
「セッションを停止する」セクションawait CapacitorUwb.stopSession();Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.ts. TypeScript の型定義を更新し、実行します bun run docgen プラグインのリポジトリで、生成された API ドキュメントを更新します。