Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didExitRegion not fired when turn off bluetooth

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

like image 312
Kepa Santos Avatar asked Sep 27 '22 17:09

Kepa Santos


1 Answers

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.

like image 101
davidgyoung Avatar answered Oct 13 '22 01:10

davidgyoung