关闭蓝牙时未触发didExitRegion [英] didExitRegion not fired when turn off bluetooth

查看:92
本文介绍了关闭蓝牙时未触发didExitRegion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBeacon构建一个简单的ios应用,正在监视区域,但是输入和退出事件存在一些问题.

Im building a simple ios app with IBeacon, I'm monitoring a region but I have some issues with enter and exit events.

如果我进入某个区域,则会触发回调didEnterRegion,但是在该区域之内,关闭蓝牙不会触发didExitRegion回调.这是预期的行为吗?

If I go into a region the callback didEnterRegion is fired, but being within the region, turning off bluetooth doesn't fire didExitRegion callback. Is this the expected behavior?

这是一个问题,因为我必须能够检测到用户何时退出该区域.有什么主意吗?

This is an issue since I have to be able to detect when the user exits the region. Any idea?

谢谢

推荐答案

出于测试目的,您必须关闭信标或移出范围以获取didExitRegion事件.

For testing purposes you must turn off your beacons or move out of range to get a didExitRegion event.

一旦CoreLocation确定它在CLBeaconRegion内部,它只有在有机会进行蓝牙扫描3秒钟后才会将状态更改为该区域之外,在此期间没有与CLBeaconRegion匹配的信标检测到.如果蓝牙未打开,则无法扫描以进行此确定.

Once CoreLocation has determined it is inside a CLBeaconRegion it will only change state to being outside the region after it has a chance to do a Bluetooth scan for 3 seconds during which time no beacons matching the CLBeaconRegion are detected. If Bluetooth is not on, it cannot scan to make this determination.

如果在这种情况下要在应用中强制退出,请考虑监听CoreBluetooth生命周期事件.关闭电源后,您可以注销每个CLBeaconRegion,手动触发didExitRegion逻辑,然后使用CoreLocation注销它们.

If you want to force an exit in your app in this case, consider listening for CoreBluetooth lifecycle events. On power off, you can deregister each CLBeaconRegion, fire your didExitRegion logic manually, then deregister them with CoreLocation.

这篇关于关闭蓝牙时未触发didExitRegion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆