简体   繁体   中英

iOS - Scan BLE devies in background

I have noticed that scanForPeripheralsWithServices is not working in background. I tried with following:

  1. specified UUID and option nil
  2. set UIBackgroundModes bluetooth-central and bluetooth-peripheral info.plist

I want a background service that should scan BLE devices in background continuously. Thanks for your help!

Background mode works differently for scanning.

Every peripheral is only reported the first single time it is observed (you cannot track proximity through RSSI without connecting to it while in background mode).

You can initiate a connect request to a peripheral that's not within range, and the connection will complete when the peripheral becomes available. Don't have to actively scan for this (except for initial discovery, so you know which UUID to connect).

Maybe, you can solve the problem by sending a connect request instead of scanning, while in background. This way, iOS knows that you are really interested in a specific peripheral and I could imagine that this affects discovery times.

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