onBluetoothAdapterStateChange

Requires:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { onBluetoothAdapterStateChange } from '@ray-js/ray';

// Promise usage
try {
  const res = await onBluetoothAdapterStateChange({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
onBluetoothAdapterStateChange(listener: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 5.2.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.2.0

Description

Listen for Bluetooth adapter state changes; Bluetooth permission is required

Parameters

ParameterTypeRequiredDescription
(params: ) => voidYes

Return Value

None

Examples

import { onBluetoothAdapterStateChange } from '@ray-js/ray'

// Listen for Bluetooth adapter state changes; the callback indicates availability when toggling Bluetooth on the phone
onBluetoothAdapterStateChange(e => {
  console.log("Bluetooth adapter available:", e.available);
});
// State changes require toggling Bluetooth; keep listening for a while
await new Promise(resolve => setTimeout(resolve, 8000));