蓝牙低功耗__CAPGO_KEEP_0__插件:安装、设置与示例
返回插件
@capgo/capacitor-低功耗蓝牙
教程
@capgo/capacitor-低功耗蓝牙

低功耗蓝牙

全功能BLE插件,用于扫描、连接、读取、写入和接收蓝牙设备的通知

{"targetLanguage":"Simplified Chinese"}

"指南"

"蓝牙低功耗教程"

Download the Capgo app, then scan the QR code.

"蓝牙低功耗插件预览code"

"使用@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();

全参考

继续使用@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 中, 和 添加或更新插件 为实现细节在添加或更新插件.