这有可能设定唤醒距离吗?如果可能,如何设置唤醒距离/最小rssi?
我想设置唤醒应用程序的最小距离是5米或设置为最小的rssi值。现在,我只能从信标唤醒应用程序,根据其默认范围唤醒。
我正在使用Swift 3开发应用程序。
发布于 2017-05-02 13:17:53
iOS CoreLocation API不提供设置从信标监视回调的最小距离的能力。实现类似目标的常用方法是使用信标测距。
您可以通过同时开始监视和测距来完成这一任务:
locationManager?.startMonitoring(for: region)
locationManager?.startRangingBeacons(in: region)
当第一次检测到信标时,监控回调会在后台唤醒应用程序,并且测距将自动启动。然后,在测距回调中,只有在满足最小距离条件时才执行逻辑:
func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
for beacon in beacons {
// Is beacon less than 5 meters away?
if beacon.accuracy < 5.0 {
// Custom logic here
}
}
对此有几点警告:
https://stackoverflow.com/questions/43733736
复制相似问题