react-native-bluetooth-state-manager
Version:
Manage the bluetooth state of your device
34 lines (33 loc) • 986 B
JavaScript
;
import { NitroModules } from 'react-native-nitro-modules';
const module = NitroModules.createHybridObject('BluetoothStateManager');
export const BluetoothStateManager = {
getState: () => module.getState(),
getStateSync: () => module.getStateSync(),
/**
* Opens the bluetooth settings page
*/
openSettings: () => module.openSettings(),
/**
* Get called whenever the bluetooth state changes
*/
addListener: (callback, emitCurrentState = true) => {
if (emitCurrentState) {
callback(module.getStateSync());
}
const callbackRef = module.addListener(callback);
return () => {
module.removeListener(callbackRef);
};
},
/**
* Requests the user to enable bluetooth
*/
requestToEnable: () => module.requestToEnable(),
/**
* Requests the user to disable bluetooth
*/
requestToDisable: () => module.requestToDisable(),
dispose: () => module.dispose()
};
//# sourceMappingURL=BluetoothStateManager.js.map