无法蓝牙设备连接在IOS 8连现有的代码没有找到蓝牙和它回环在iOS 7极细的主要事情(unable

2019-10-21 02:12发布

问题连接的蓝牙设备,如在IOS 8连现有的代码没有找到蓝牙腕带和主要的东西它的工作在iOS 7..my代码很细的是建议我任何想法或蓝牙iOS 8的变化..

-(void)connecttodevice { 
     // Scan for all available CoreBluetooth LE devices 
     NSArray *services = @[[CBUUID UUIDWithString:info_UUID],[CBUUID UUIDWithString:info_UUID_service],[CBUUID UUIDWithString:BAND_SERVICE_INFO]]; 
     NSLog(@"device connting....."); 
     CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; 
     [centralManager scanForPeripheralsWithServices:services options:nil]; 
     self.centralManager = centralManager; 
 } 

Answer 1:

你的问题是,你正在创建的CBCentralManager而不是等到中央管理器是在状态的动力作为指示后,立即调用scanForPeripheralsWithServices centralManagerDidUpdateState代表。

- (void)centralManagerDidUpdateState:(CBCentralManager *)central

     if (central.state == CBCentrallManagerStatePoweredOn {
        NSArray *services = @[[CBUUID UUIDWithString:info_UUID],[CBUUID UUIDWithString:info_UUID_service],[CBUUID UUIDWithString:BAND_SERVICE_INFO]]; 
        NSLog(@"device connting....."); 
        [central scanForPeripheralsWithServices:services options:nil];
     }
}

在iOS中7开始扫描,显示通电状态下前发出的控制台上的警告。 在iOS中8不开始扫描。



文章来源: unable to connect bluetooth device in ios 8 even existing code not finding bluetooth and main thing it woring very fine on ios 7