简体   繁体   中英

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.

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. If RSSI < -70, cancel the connection. 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! I will be very grateful.

I think iOs only enables your background mod for a few mins. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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