swift - CoreBluetooth XPC 连接无效错误和 Info.plist 添加
问题描述
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 屏幕发送消息。ESP32 与我从 App Store 下载的 BLE 扫描仪应用程序配合良好。
解决方案
推荐阅读
- python - 如何循环遍历 django 中的对象字段
- php - 访问包含文件中的 url 参数?
- swift - Swift 5在上传前将图像大小调整为像素大小
- javascript - 如果我将 URL 添加到 waitUntil() 流之外的服务工作者缓存会发生什么?
- flutter - Flutter - 如何在滚动时使一行保持在屏幕顶部
- docker - 从 docker 容器内部使用 AI 模型的最佳实践
- node.js - 如何从 ApiGateway 缓存资源中获取内容编码
- java - 阿帕奇骆驼 | 弹簧测试 | 拦截路线不起作用
- oop - 继承和聚合类关系是否与所有权相关?
- c - 打印 FILE 变量的内容