didExitRegion not fired when turn off bluetooth

人走茶凉 提交于 2019-12-10 13:51:53

问题


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

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?

Thanks


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/30640270/didexitregion-not-fired-when-turn-off-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!