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
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 aCLBeaconRegion
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 theCLBeaconRegion
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 eachCLBeaconRegion
, fire yourdidExitRegion
logic manually, then deregister them withCoreLocation
.