1.0.2 • Published 4 years ago
rn-scan-bt-device v1.0.2
React Native Library for Bluetooth
This library is used to enable bluetooth, get list of paired bluetooth devices and also get the list of availble bluetooth devices
Getting started
Installing it as a library in your main project
``` npm i rn-scan-bt-device or yarn add rn-scan-bt-device ```
For android you also need to put the following code to AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Simply
import
it by the name defined in your library'spackage.json
:import ScanBluetooth from 'rn-scan-bt-device';
Example:
<!-- check bluetooth is enable or not --> ScanBluetooth.isBluetoothEnable().then((isEnable) =>{ console.log("isEnable", isEnable); }).catch( error => { console.log("error", error); }); <!-- enable bluetooth --> ScanBluetooth.enableBluetooth().then((value) =>{ console.log("value", value); }).catch( error => { console.log("error", error); }); <!-- get list of paired devices --> ScanBluetooth.getListOfPairedDevices((err, devices) =>{ console.log("paired devices", devices); console.log("err", err); }); <!-- get list of available devices --> ScanBluetooth.getDiscoverDevices((err, devices) =>{ console.log("available devices", devices); console.log("err", err); });