gpt4 book ai didi

ios - 无法发现外围蓝牙低功耗设备

转载 作者:行者123 更新时间:2023-11-29 02:50:11 26 4
gpt4 key购买 nike

我最近将手机升级到 iOS Beta 版本 8 并安装了我的 iOS 应用程序。不幸的是,我的应用程序无法再发现我的外围 BLE 设备。我检查了任何说明是否有任何更改的文档,但没有发现。是否有任何已知的 API 更改作为 iOS 8 的一部分引入?我正在 iPhone 5s 上进行测试我的代码之前可以在 IOS 版本 7.xx 上运行

相关代码:

[self.CM scanForPeripheralsWithServices:nil options:nil];

最佳答案

您在哪里启动扫描?你应该打电话

self.CM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

在 viewDidLoad 或任何其他您需要的地方,然后仅在centralmanager状态打开时扫描外围设备:

-(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; }

关于ios - 无法发现外围蓝牙低功耗设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24646137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com