0

我正在开发 BLE 应用程序,我需要在后台模式下扫描设备。在调试时,我发现它扫描了设备,但没有调用并返回设备的发现。在前台模式下一切正常。

为什么我的应用在后台运行时无法扫描设备?

注意:我确实输入了所需的后台模式 1.App 使用 CoreBluetooth 进行通信 2.App 使用 CoreBluetooth 共享数据。下面是我在前台调用扫描设备的代码

[[LGCentralManager sharedInstance] scanForPeripheralsByInterval:1 completion:^(NSArray *peripherals) {
      // If we found any peripherals sending to test
      if (peripherals.count > 0) {
         for (LGPeripheral *peripheral in peripherals) {
              if (peripheral.advertisingData) {
         }
      }
}]; 

输出广告数据:

Printing description of peripheral->_advertisingData:
        {
            kCBAdvDataIsConnectable = 1;
            kCBAdvDataLocalName = "Device Name";
            kCBAdvDataServiceUUIDs =     (
                "00000000-64B0-5B82-3F51-000000027D2"
            );
            kCBAdvDataTxPowerLevel = "-2";
        }
4

0 回答 0