简体   繁体   中英

Swift: Start ble scan from beacon wake

have an application that is wake by an ibeacon, the application is wake it starts a scan.

When the screen is off the scan not seem to work, that I turn on the screen the scan the scan return results. I understand the scan does not work if the screen is off. How to make Start Scan via Beacon advertisement?

I think before that worked, I am on ios 15. I did not check on iOS14, but on iOS 13 the scan worked when the screen was off, I just did not have access to advertisement data

In order to get bluetooth events in the background, you need to make sure your Info.plist declares this:

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

If that is not present, you absolutely will not get callbacks to didDiscoverPeripheral in the background.

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