简体   繁体   English

Swift:从信标唤醒开始 ble 扫描

[英]Swift: Start ble scan from beacon wake

have an application that is wake by an ibeacon, the application is wake it starts a scan.有一个被 ibeacon 唤醒的应用程序,该应用程序被唤醒它开始扫描。

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?如何通过 Beacon 广告开始扫描?

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我认为在此之前,我使用的是 ios 15。我没有检查 iOS14,但是在 iOS 13 上,屏幕关闭时扫描工作,我只是无法访问广告数据

In order to get bluetooth events in the background, you need to make sure your Info.plist declares this:为了在后台获取蓝牙事件,您需要确保您的 Info.plist 声明:

        <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.如果不存在,您绝对不会在后台获得对didDiscoverPeripheral回调。

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

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