概述
概述Capacitor 蓝牙低能耗插件用于 BLE 通信。
核心功能
概述initialize- 初始化 BLE 插件。必须在调用任何其他方法之前调用。shimWebBluetooth- 安装 Capacitor Web Bluetooth shimnavigator.bluetooth- 在 Capacitor 原生应用中,手动调用此 shim 之前使用 Web Bluetooth APIisAvailable- 检查设备上是否有蓝牙可用isEnabled- 检查设备蓝牙是否已启用
公共 API
公共 API| 方法 | 描述 |
|---|---|
initialize | 初始化 BLE 插件。必须在调用任何其他方法之前 |
shimWebBluetooth | 安装 Capacitor Web Bluetooth shim navigator.bluetooth- 在 Capacitor 原生应用中,手动调用此 shim 之前使用 Web Bluetooth API |
isAvailable | 检查设备上是否有蓝牙可用 |
isEnabled | 检测设备上的蓝牙是否启用。 |
isLocationEnabled | 检测设备是否开启位置服务(仅限 Android)。 |
openAppSettings | 打开应用设置页面。 |
openBluetoothSettings | 打开蓝牙设置页面(仅限 Android)。 |
openLocationSettings | 打开位置设置页面(仅限 Android)。 |
checkPermissions | 检查当前权限状态。 |
requestPermissions | 请求蓝牙权限。 |
startScan | 开始扫描BLE设备。 |
stopScan | 停止扫描BLE设备。 |
connect | 连接BLE设备。 |
disconnect | 断开BLE设备的连接。 |
createBond | 与BLE设备建立绑定(仅限 Android)。 |
isBonded | 检测设备是否已绑定(仅限Android)。 |
discoverServices | 发现已连接设备上的服务。 |
getServices | 获取设备上的已发现服务。 |
getConnectedDevices | 获取已连接设备的列表。 |
readCharacteristic | 读取特性值。 |
writeCharacteristic | 将值写入特性。 |
startCharacteristicNotifications | 为特性启动通知。 |
stopCharacteristicNotifications | 为特性停止通知。 |
readDescriptor | 读取描述符值。 |
writeDescriptor | 将值写入描述符。 |
readRssi | 读取已连接设备的RSSI(信号强度)。 |
requestMtu | 请求MTU大小更改(仅限Android)。 |
requestConnectionPriority | 请求连接优先级(仅限 Android)。 |
startAdvertising | 作为 BLE 服务器开始广播。 |
stopAdvertising | 停止广播。 |
startForegroundService | 启动前台服务以在后台维护 BLE 连接(仅限 Android)。 |
stopForegroundService | 停止前台服务(仅限 Android)。 |
getPluginVersion | 获取本机 Capacitor 插件版本。 |
addListener | 添加设备扫描事件的监听器。 |
addListener | 添加设备连接事件的监听器。 |
addListener | 添加设备断开连接事件的监听器。 |
addListener | 添加特征变化事件的监听器。 |
removeAllListeners | 移除此插件的所有监听器。 |
真实数据源
Section titled “数据源”本参考文档是从 src/definitions.ts in capacitor-低功耗蓝牙.
Keep going from @capgo/capacitor-低功耗蓝牙
Section titled “Keep going from @capgo/capacitor-低功耗蓝牙”如果您正在使用 @capgo/capacitor-低功耗蓝牙 连接它以规划迁移和企业运营 Using @capgo/capacitor-低功耗蓝牙 for the native capability in Using @capgo/capacitor-低功耗蓝牙 Capgo 企业 为Capgo企业产品流程 Ionic 企业插件替代品 为Ionic 企业插件替代品的产品流程 Capgo替代品 为Capgo替代品的产品流程,并且 Capgo咨询 为Capgo咨询的产品流程