Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
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.
Install
Section titled “Install”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-uwb` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
bun add @capgo/capacitor-uwbbunx cap syncImport
Section titled “Import”import { CapacitorUwb } from '@capgo/capacitor-uwb';Check Availability
Section titled “Check Availability”const availability = await CapacitorUwb.isAvailable();
if (!availability.supported) { console.log('This device does not support UWB.');}iOS Peer Session
Section titled “iOS Peer Session”- Call
getDiscoveryToken()on both devices. - 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
Section titled “Android Controller / Controlee Session”- The controller calls
startControllerSession()and shares the returnedrangingParametersandlocalAddress. - The controlee builds its own
rangingParameters, using the controllerlocalAddressaspeerAddress. - The controlee calls
startControleeSession({ rangingParameters }). - Optionally pass
peerAddressto the controller once the controlee address is known.
const controller = await CapacitorUwb.startControllerSession();
await CapacitorUwb.startControleeSession({ rangingParameters: { ...controller.rangingParameters, peerAddress: controller.localAddress, },});See Android setup for hardware and permission requirements.
Listen For Updates
Section titled “Listen For Updates”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
Section titled “Stop The Session”await CapacitorUwb.stopSession();Source Of Truth
Section titled “Source Of Truth”This page is generated from the plugin’s src/definitions.ts. Update the TypeScript definitions and run bun run docgen in the plugin repository to refresh the generated API docs.