ios - 进入后台时 BLE 扫描停止?

标签 ios bluetooth bluetooth-lowenergy core-bluetooth

我正在扫描硬件设备。 在前台时,我可以看到设备。 当我在前台开始扫描,然后转到后台,然后打开硬件 BLE,扫描停止,应用程序无法检测到硬件。

如果我将应用重新打开到前台,它会继续扫描并找到设备。

我已经设置了键:

  <string>bluetooth-peripheral</string>
        <string>bluetooth-central</string>

还有背景模式:

location updates
external accessory communication
uses BLE accessories
acts as BLE ACCESSORY

但什么也没有。系统不允许我在后台检测设备,只能在前台检测。

我错过了什么?

最佳答案

发现您必须设置您在后台查找的服务 ID,否则它将无法工作。 无论如何,后台扫描非常慢并且可能需要几分钟才能检测到!!

 [_centralManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:DEVICE_INFO_SERVICE_UUID]]

关于ios - 进入后台时 BLE 扫描停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27111338/

相关文章:

iOS:为什么我不能从全局 block (方法之外)访问@property

android - 你会如何做智能手机BLE室内检测和定位?

android - BLE GATT 服务器名称

iphone - 2 台 iOS 设备之间的蓝牙连接

iphone - 动态更新 UITableView 部分标题

ios - 所有行中显示的最后一条记录

ios - 在 Cocoa Touch Framework 中包装静态库

ios - pjsip ios : Bluetooth not working

java - 应用程序在 Android Studio 中崩溃。 getMenuInflater().inflate(R.menu.activity_main, 菜单);不存在?

ios - 是什么让某些蓝牙设备在 iOS "My Devices"上列出?