Ios 无法发现外围蓝牙低能耗设备
我最近将手机升级到iOS Beta版本8,并安装了iOS应用程序。不幸的是,我的应用程序无法再发现我的外设Ios 无法发现外围蓝牙低能耗设备,ios,iphone,bluetooth-lowenergy,ios8,Ios,Iphone,Bluetooth Lowenergy,Ios8,我最近将手机升级到iOS Beta版本8,并安装了iOS应用程序。不幸的是,我的应用程序无法再发现我的外设BLE设备。我查看了所有说明是否有任何更改的文档,但没有发现任何更改。是否有任何已知的API更改作为iOS 8的一部分引入?我正在测试iphone5s 我的代码以前在IOS 7.xx版上运行 相关代码: [self.CM scanForPeripheralsWithServices:nil options:nil]; 你在哪里启动扫描? 你应该打电话 self.CM = [[CBCentr
BLE
设备。我查看了所有说明是否有任何更改的文档,但没有发现任何更改。是否有任何已知的API更改作为iOS 8的一部分引入?我正在测试iphone5s
我的代码以前在IOS 7.xx版上运行
相关代码:
[self.CM scanForPeripheralsWithServices:nil options:nil];
你在哪里启动扫描? 你应该打电话
self.CM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
在viewDidLoad或其他任何您需要的位置,仅当centralmanager状态为on时,才扫描外围设备:
-(void)centralManagerDidUpdateState:(CBCentralManager *)central{ switch (central.state) {
case CBCentralManagerStatePoweredOff:
NSLog(@"CoreBluetooth BLE hardware is powered off");
break;
case CBCentralManagerStatePoweredOn:
{
NSLog(@"CoreBluetooth BLE hardware is powered on and ready");
[self.CM scanForPeripheralsWithServices:nil options:nil];
}
break;
case CBCentralManagerStateResetting:
NSLog(@"CoreBluetooth BLE hardware is resetting");
break;
case CBCentralManagerStateUnauthorized:
NSLog(@"CoreBluetooth BLE state is unauthorized");
break;
case CBCentralManagerStateUnknown:
NSLog(@"CoreBluetooth BLE state is unknown");
break;
case CBCentralManagerStateUnsupported:
NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform");
break;
default:
break; }
另见此答案: