繁体   English   中英

iOS BLE scanForPeripheralsWithServices:options:在背景上

[英]IOS BLE scanForPeripheralsWithServices:options: on Background

CentralManager不会在后台扫描BLE设备。

我已经在info.plist中设置了UIBackgroundModesbluetooth-central )。

还尝试输入UUID这样的服务。

[CentralManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"0xFFA0"]] options:nil];

(0xFFA0是用于服务的UUID。)

还尝试了"C337FA9-4DCF-****-77AB-************"; 设备的UUID。 无论我将UUID放入“服务”中。 在后台找不到任何设备。

当前景.. scanForPeripheralsWithServices:nil找到所有设备时。 但不是scanForPeripheralsWithServices:someuuids

谁能帮我?

1.如果您使用

scanForPeripheralsWithServices:someuuids

必须有一些设备使用此uuid来宣传蓝牙数据包。这可以在前景和后景中很好地工作

2,如果您使用

scanForPeripheralsWithServices:nil

您可以获取所需的所有设备,但是在后台运行时不起作用。

因此,如果要在后台获取结果,则必须设置外围设备使用UUID通告BLE数据包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM