-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
wklm edited this page Mar 18, 2026
·
1 revision
This page covers the shortest path to using iOSWebBLE in a web app.
- Plain Web Bluetooth support across Safari iOS, Chrome, and Edge: install
@ios-web-bluetooth/core - iOS Safari install prompts and extension detection: add
@ios-web-bluetooth/detect - React hooks and components: add
@ios-web-bluetooth/react
npm install @ios-web-bluetooth/core @ios-web-bluetooth/detectimport { initIOSWebBLE, isIOSSafari } from '@ios-web-bluetooth/detect';
import { WebBLE, WebBLEError } from '@ios-web-bluetooth/core';
if (isIOSSafari()) {
await initIOSWebBLE({
operatorName: 'MyApp',
banner: { mode: 'sheet', dismissDays: 14 },
onReady: () => console.log('Extension ready'),
onNotInstalled: () => console.log('Prompting install'),
});
}
const ble = new WebBLE();
async function connect() {
try {
const device = await ble.requestDevice({
filters: [{ services: ['heart_rate'] }],
});
await device.connect();
const value = await device.read('heart_rate', 'heart_rate_measurement');
console.log('Heart rate:', value.getUint8(1));
} catch (err) {
if (err instanceof WebBLEError) {
console.error(err.code, err.suggestion);
}
}
}
document.getElementById('connect')?.addEventListener('click', connect);requestDevice() must run from a direct user gesture like a click or tap handler. Do not call it from page load, DOMContentLoaded, setTimeout, or useEffect.
If you are not using a bundler, load the hosted script:
<script src="https://ioswebble.com/webble.js"></script>- BLE API walkthrough: Core SDK
- Install prompts and detection: Extension Detection
- React apps: React SDK
- Hosted docs: https://ioswebble.com/docs