CoreBluetooth XPC连接无效错误并添加了Info.plist

时间:2018-07-01 16:17:44

标签: swift

override func viewDidLoad() {
    super.viewDidLoad()

    ref = Database.database().reference()
    title = "cry"
    //self.delegate = delegate
    centralManager = CBCentralManager.init(delegate: self, queue: .main)            
}

extension ComposeViewController: CBCentralManagerDelegate, CBPeripheralDelegate {

func centralManagerDidUpdateState(_ central: CBCentralManager) {
    switch central.state {
    case .unknown:
        print("unknoe")
    case .resetting:
        print("reset")
    case .unsupported:
        print("unsupported")
    case .unauthorized:
        print("unauthorized")
    case .poweredOff:
        print("poweredoff")
    case .poweredOn:
        print("poweron")

        centralManager.scanForPeripherals(withServices: [CBUUID.init(string: Service_UUID)])
    }
}


func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    self.peripheral = peripheral
    print("discover peripheral")


    centralManager.connect(peripheral, options: nil)
}

我收到以下消息:

  

[CoreBluetooth] XPC连接无效

我能够获得开机消息,并且好像无法扫描BLE设备。我在“ Infoplist”中为“隐私”蓝牙外围设备使用说明NSBluetoothPeripheralUsageDescription添加了价值,但没有运气。

我尝试连接ESP32并向LCD屏幕发送消息。我从App Store下载的BLE扫描仪应用程序与ESP32配合良好。

0 个答案:

没有答案