1

I was given a react native application to work with bluetooth headset. By using the following code I was able to detect the bluetooth device connectivity on/off and alert the end user. But addition to these I was asked to fetch the battery level and some more information and some more features to be implemented with the mobile application like control the volume level of the headset through the mobile application. Is there are any react native library which we can use for this purpose apart from the following code ?

import { NativeEventEmitter, NativeModules } from "react-native"

const BluetoothHeadsetDetectModule = NativeModules.RNBluetoothHeadsetDetect
const bluetoothHeadsetDetectEmitter = new NativeEventEmitter(
    BluetoothHeadsetDetectModule
)

export default class MainScreen extends Component {
componentDidMount() {
        bluetoothHeadsetDetectEmitter.addListener("onChange", ({ devices }) => {    
            if (devices.length && devices == "xxxx") {

            }
        })
    }
}

Hoetmaaiers
  • 3,413
  • 2
  • 19
  • 29
Ruchira Chamara
  • 345
  • 2
  • 7
  • 20
  • Is [this](https://stackoverflow.com/questions/19539535/how-to-get-the-battery-level-after-connect-to-the-ble-device) useful for you? – 高鵬翔 Apr 16 '20 at 02:17
  • Yes for some level only for the android. But I am looking for iOS as well and for the volume controlling functionalities as well!. Thanks. – Ruchira Chamara Apr 16 '20 at 02:27

0 Answers0