简体   繁体   English

屏幕打开时进行iOS BLE扫描

[英]iOS BLE scanning when screen is on

We are developing a BLE application using iBeacons on iOS. 我们正在iOS上使用iBeacons开发BLE应用程序。 We want to display a notification when the user is within the iBeacon region as fast as possible (ideally within 2seconds when he reachs the region). 我们希望在用户尽快进入iBeacon区域时(最好是到达该区域后2秒内) 显示通知

Two questions: 两个问题:

  1. Is the Region Monitoring API always called when the user clic on the home button and screen turns on ? 用户单击主页按钮并打开屏幕时,是否总是调用Region Monitoring API?

  2. If the user is already using the mobile phone (screen is on), the BLE app is not running at all even in background and he approches the beacon: is there a way to force the Region Monitoring API to be called? 如果用户已经在使用移动电话(屏幕处于打开状态),则BLE应用程序甚至根本不在后台运行,而他使用了信标:是否有一种方法可以强制调用Region Monitoring API? Because now, we need to wait several minutes in order to get a notification. 因为现在,我们需要等待几分钟才能收到通知。

Thanks a lot for your kind help ! 非常感谢您的帮助! David 大卫

You can turn on Background Mode for your app. 您可以为您的应用打开“背景模式”。 Check UIBackgroundModes in apple docs. 检查appledocs中的UIBackgroundModes。 There are Bluetooth LE accessories Modes that can handle the background scanning and checking of iBeacons(Even when the screen is off). 有蓝牙LE附件模式,可以处理iBeacons的后台扫描和检查(即使屏幕关闭)。

You can check the background modes documentation at https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html 您可以在https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html上查看后台模式文档。

CLLocationManager具有以下方法:

open func startRangingBeacons(in region: CLBeaconRegion)

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

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