iOS Setup
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
iOS native system used
Section titled “iOS native system used”On iOS, this plugin uses Nearby Interaction from the NearbyInteraction framework.
Requirements
Section titled “Requirements”- iOS 15+
- Physical device with UWB hardware
- Nearby Interaction capability enabled in Xcode
Xcode setup
Section titled “Xcode setup”- Open your iOS app target in Xcode.
- Go to Signing & Capabilities.
- Click + Capability and add Nearby Interaction.
- Add a usage description to
Info.plist:
<key>NSNearbyInteractionUsageDescription</key><string>This app uses Ultra Wideband to measure distance to nearby devices.</string>Client flow
Section titled “Client flow”import { CapacitorUwb } from '@capgo/capacitor-uwb';
const { discoveryToken } = await CapacitorUwb.getDiscoveryToken();
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: '<peer-token-base64>', isCameraAssistanceEnabled: false,});Share each device’s discoveryToken with the other peer using your own transport layer. The plugin does not perform discovery or networking for you.
Events
Section titled “Events”rangingUpdateemits distance and direction updates when available.sessionStateChangedemits lifecycle states such asrunning,suspended,invalidated, andpeerDisconnected.
getDiscoveryToken()andstartPeerSession()are iOS-only APIs.- Camera assistance is available on iOS 16+ when supported by the device.