What causes CBCentralManagerStateUnknown in iOS?

后端 未结 6 2735
灰色年华
灰色年华 2021-02-20 06:15

Why do I get CBCentralManagerStateUnknown on an iPad 2 when using this simple code?

- (BOOL)viewDidLoad {

    bluetoothManager = [[CBCentralManager         


        
6条回答
  •  庸人自扰
    2021-02-20 06:51

    If a central's state goes to CBCentralManagerStateUnsupported (while Bluetooth Low Energy is supported by the device) it most likely means the app has done something bad with CoreBluetooth.

    Check the iOS Bluetooth Diagnostic Logging logs.

    For example, if you do this...

    _cm1 = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{ CBCentralManagerOptionRestoreIdentifierKey: @"not_unique" }]; _cm2 = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{ CBCentralManagerOptionRestoreIdentifierKey: @"not_unique" }];

    ... the second central's state will go to CBCentralManagerStateUnsupported.

提交回复
热议问题