简体   繁体   English

BLE后台扫描无法快速进行

[英]BLE Background scan is not working in swift

manager?.scanForPeripherals(withServices: [CBUUID.init(string: "FE50")], options: [CBCentralManagerScanOptionAllowDuplicatesKey: true])

<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>

I have turned background mode to on, and added [CBUUID] of services during scanning. 我已打开后台模式,并在扫描期间添加了[CBUUID]服务。

I can find the device from this service when I am in the foreground, but I can't find the device when I am in the background. 当我在前台时,可以从此服务中找到设备,但是当我在后台时,则找不到该设备。

The app needs to be connected to a device with a door lock. 该应用程序需要连接到带门锁的设备。 If RSSI > -50 when scanning, open the door after connecting. 如果扫描时RSSI> -50,则在连接后打开门。 If RSSI < -70, cancel the connection. 如果RSSI <-70,请取消连接。 This behavior pattern is normal in the foreground, but it is not normal in the background. 此行为模式在前台是正常的,但在后台是不正常的。

Please give me some advice , I have been stuck for 1 week! 请给我一些建议,我被困了1周! I will be very grateful. 我将非常感谢。

I think iOs only enables your background mod for a few mins. 我认为iOs只会启用您的后台mod几分钟。 if you want to make it longer than an hour, you need to make some way around. 如果您想使其超过一个小时,则需要采取一些措施。 This is a good source if you want to make it longer, but I won't be approved in the store I believe. 如果您想延长它的时间,这是一个很好的来源 ,但是我相信我不会在这家商店中获得批准。

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

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