1.0.2 • Published 4 years ago

rn-scan-bt-device v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

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" />
  1. Simply import it by the name defined in your library's package.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);
    });
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago