I want to scan Bluetooth in app kill mode. I don't need to connect the device just scan, It's working in background mode I am using react-native-ble-plx plugin
I am trying to scan Bluetooth when React native application is closed
useFocusEffect(
useCallback(() => {
//const manager = new BleManager();
const manager = new BleManager();
const subscription = manager.onStateChange((state) => {
if (state === "PoweredOn") {
manager.startDeviceScan(
["0000feaa-0000-1000-8000-00805f9b34fb"],
{ allowDuplicates: true, ScanMode: ScanMode.LowLatency },
(error, device) => {
if (error) {
console.log("scaned device-error", error);
// Handle error (scanning will be stopped automatically)
return;
}
beaconAction(device);
}
);
return () => {
subscription.remove();
manager.stopDeviceScan();
};`
}
}, true);
}, [])
);