スタート
このプラグインのインストール手順と全マークダウンガイドを含むセットアップの質問をコピーする。
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.
インストール
「インストール」というタイトルのセクションCapgoのAI-Assisted Setupを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。
npx 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.Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-uwbbunx cap syncインポート
「インポート」のセクションimport { CapacitorUwb } from '@capgo/capacitor-uwb';利用可能性を確認
「利用可能性を確認」のセクションconst availability = await CapacitorUwb.isAvailable();
if (!availability.supported) { console.log('This device does not support UWB.');}iOS ペア セッション
「iOS ペア セッション」のセクション- 呼び出し
getDiscoveryToken()両方のデバイスで。 - Exchange the returned base64 tokens out-of-band.
- Start ranging with the peer token.
const { discoveryToken } = await CapacitorUwb.getDiscoveryToken();
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: '<peer-token-base64>',});See iOS setup for capability and permission requirements.
Android Controller / Controlee Session
Android Controller / Controlee Session- The controller calls
startControllerSession()and shares the returnedrangingParametersandlocalAddress. - The controlee builds its own
rangingParameters, コントローラーを使用します。localAddressとしてpeerAddress. - コントロールされる側がコントローラーに呼び出します。
startControleeSession({ rangingParameters }). - コントロールされる側のアドレスがわかったら、コントローラーに渡すことができます。
peerAddressクリップボードにコピー
const controller = await CapacitorUwb.startControllerSession();
await CapacitorUwb.startControleeSession({ rangingParameters: { ...controller.rangingParameters, peerAddress: controller.localAddress, },});ハードウェアとパーミッションの要件については、 更新を待つ セクション “更新を待つ”
クリップボードにコピー
protectedTokensawait CapacitorUwb.addListener('rangingUpdate', (event) => { console.log(event.distanceMeters, event.direction);});
await CapacitorUwb.addListener('sessionStateChanged', (event) => { console.log(event.state, event.reason);});セッションを停止する
セクション「セッションを停止する」await CapacitorUwb.stopSession();真実の源
セクション「真実の源」このページはプラグインから生成されています。 src/definitions.tsTypeScript定義を更新し、生成されたドキュメントを更新するには、 bun run docgen in the plugin repository to refresh the generated API docs.