jcamacho
jcamacho

Reputation: 938

centralManagerDidUpdateState always return PoweredOff

In my app I check if bluetooth is turn on, if is turn off I show alert to the user in order to enable it. For this functionality I using centralManagerDidUpdateState and check [central state]. On iOs 10 device works fine, but, on iOs 11 doesn't work, always return CBCentralManagerStatePoweredOff after do this:

1.- I go to configuration and I turn off the bluetooth.

2.- I open the app, the centralManagerDidUpdateState call back is called and PoweredOff is detect.

3.- I go to configuration and I turn on the bluetooth.

4.- I back to the app, and centralManagerDidUpdateState is called and PoweredOff is still the state when the bluetooth is On.

Is this issue an iOs 11 bug?, anyone knows any solution for check the bluetooth is turn on?

Thanks

Upvotes: 0

Views: 617

Answers (1)

efdalustaoglu
efdalustaoglu

Reputation: 168

I also faced with the same issue. I was testing BLE functionality by using this sample project "https://github.com/jasonmgeorge/BLEScanner" one device on iOS 10.3.3 and another on iOS 11.2. On iOS 10.3.3 it was working fine but on the other device, I was getting the same error all the time. Then I realized that

NSBluetoothPeripheralUsageDescription

wasn't in Info.plist, so I added. Again I got "CBCentralManagerStatePoweredOff". I went to settings to power off Bluetooth and on again. It's working magically. It's a iOS 11 bug most probably. Please check your implementation. It's not very consistent but sometimes it works.

Upvotes: 1

Related Questions