React Native Ble Manager, [CoreBluetooth] API MISUSE: <CBCentralManager: 0x...> can only accept this command while in the powered on state
[CoreBluetooth] API MISUSE: <CBCentralManager: 0x2821e4120> has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported
[CoreBluetooth] XPC connection invalid
[CoreBluetooth] API MISUSE: <CBCentralManager: 0x2821e4120> can only accept this command while in the powered on state
블루투스 주변 장치 정보를 얻고 싶어서
React Native Ble Manager 사용하다가 (버튼 눌렀을 때 스캔 X)
위와 같은 오류들이 났는데 아래 사이트의
how to I solve [CoreBluetooth] API MISUSE: can only accept this command while in the powered on state in swift 4?
I created one iOS app which search nearest bluetooth device. But when I run this app on iPhone then below error occure [CoreBluetooth] API MISUSE: can only accept this command while in the pow...
stackoverflow.com
아래와 같은 답변 덕분에 해결 방법을 찾았다
결론은
그냥 스캔하는게 아니라
현재 상태가 변경되면 스캔을 해줘야하는 것...
componentDidMount() {
...
bleManagerEmitter.addListener("BleManagerDidUpdateState",
(args) => {
if (args.state == "on") { // 상태가 변경되면
this.scan(); // 스캔
}
});
...
}
...
// 스캔
scan() {
BleManager.scan([], 5, true).then(() => {
// Success code
console.log("Scan started");
});
}