{"targetLanguage":"Simplified Chinese"}
"指南"
"使用@capgo/capacitor-bluetooth-low-energy"
"Capacitor蓝牙低功耗插件用于BLE通信。"
安装
bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync
此插件暴露的内容
initialize- 初始化BLE插件。必须在调用任何其他方法之前调用。shimWebBluetooth- 安装Capacitor Web Bluetooth shim。navigator.bluetooth. 在Capacitor原生应用中使用Web Bluetooth API之前,手动调用此方法。isAvailable- 检查设备上的蓝牙是否可用。isEnabled- 检查设备上的蓝牙是否已启用。
示例用法
initialize
初始化BLE插件。必须在调用任何其他方法之前调用。
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
await BluetoothLowEnergy.initialize({ mode: 'central' });
shimWebBluetooth
安装Capacitor Web Bluetooth shim。 navigator.bluetooth. 在Capacitor原生应用中使用Web Bluetooth API之前,手动调用此方法。
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
BluetoothLowEnergy.shimWebBluetooth();
isAvailable
检查设备上的蓝牙是否可用。
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { available } = await BluetoothLowEnergy.isAvailable();
isEnabled
检查设备上的蓝牙是否已启用.
import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';
const { enabled } = await BluetoothLowEnergy.isEnabled();
全参考
- GitHub. https://github.com/Cap-go/capacitor-bluetooth-low-energy/
- 文档:/docs/plugins/bluetooth-low-energy/
继续使用@capgo/capacitor-bluetooth-low-energy
如果您正在使用 使用@capgo/capacitor-bluetooth-low-energy 来规划原生插件工作,连接它与 @capgo/capacitor-bluetooth-low-energy 以获取@capgo/capacitor-bluetooth-low-energy中的实现细节 Getting Started 为 "Getting Started" 中的实现细节, Capgo 插件目录 为产品工作流程在 Capgo 插件目录, Capacitor 插件由 Capgo 为实现细节在 Capacitor 插件由 Capgo 中, 和 添加或更新插件 为实现细节在添加或更新插件.