Zum Hauptinhalt springen
Zurück zu Plugins
@capgo/capacitor-bluetooth-low-energy
Tutorial
@capgo/capacitor-bluetooth-low-energy

Bluetooth Low Energy

Vollwertiges BLE-Plugin für das Scannen, Verbinden, Lesen, Schreiben und Empfangen von Benachrichtigungen von Bluetooth-Geräten

Richtlinie

Tutorial zu Bluetooth Low Energy

Verwendung von @capgo/capacitor-bluetooth-low-energy

Capacitor Bluetooth Low Energy-Plugin für BLE-Kommunikation

Installieren

bun add @capgo/capacitor-bluetooth-low-energy
bunx cap sync

Was diese Erweiterung bereitstellt

  • initialize - Initialisieren Sie das BLE-Plugin. Muss vor jeder anderen Methode aufgerufen werden.
  • shimWebBluetooth - Installieren Sie den Capacitor Web Bluetooth-Stub auf navigator.bluetooth. Call this manually before using the Web Bluetooth API from a Capacitor native app.
  • isAvailable - Überprüfen Sie, ob Bluetooth auf dem Gerät verfügbar ist.
  • isEnabled - Überprüfen Sie, ob Bluetooth auf dem Gerät aktiviert ist.

Beispielhafte Verwendung

initialize

Initialisieren Sie das BLE-Plugin. Muss vor jeder anderen Methode aufgerufen werden.

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

await BluetoothLowEnergy.initialize({ mode: 'central' });

shimWebBluetooth

Installieren Sie den Capacitor Web Bluetooth-Stub auf navigator.bluetooth. Call this manually before using the Web Bluetooth API from a Capacitor native app.

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

BluetoothLowEnergy.shimWebBluetooth();

isAvailable

Überprüfen Sie, ob Bluetooth auf dem Gerät verfügbar ist.

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

const { available } = await BluetoothLowEnergy.isAvailable();

isEnabled

Überprüfen Sie, ob Bluetooth auf dem Gerät aktiviert ist.

import { BluetoothLowEnergy } from '@capgo/capacitor-bluetooth-low-energy';

const { enabled } = await BluetoothLowEnergy.isEnabled();

Vollständige Referenz

Weitermachen Sie mit Using @capgo/capacitor-bluetooth-low-energy

Wenn Sie Using @capgo/capacitor-bluetooth-low-energy zur Planung von native Plugin-Arbeiten verwenden, verbinden Sie es mit @capgo/capacitor-bluetooth-low-energy für die Implementierungsdetails in @capgo/capacitor-bluetooth-low-energy, Einstieg für die Implementierungsdetails in Getting Started, Capgo Plugin-Verzeichnis für den Produktworkflow in Capgo Plugin-Verzeichnis, Capacitor Plugins von Capgo für die Implementierungsdetails in Capacitor Plugins von Capgo, und Hinzufügen oder Aktualisieren von Plugins für die Implementierungsdetails in Hinzufügen oder Aktualisieren von Plugins.