시작하기
설치
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-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 syncimport
import 섹션import { CapacitorUwb } from '@capgo/capacitor-uwb';사용 가능 여부 확인
사용 가능 여부 확인 섹션const availability = await CapacitorUwb.isAvailable();
if (!availability.supported) { console.log('This device does not support UWB.');}iOS Peer Session
iOS Peer Session 섹션- 호출
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 설정 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, },});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();진실의 근원
“진실의 근원”이라는 제목의 섹션이 페이지는 플러그인의 src/definitions.tsTypeScript 정의를 업데이트하고 bun run docgen in the plugin repository to refresh the generated API docs.