While Testing with ibeacons in background mode, i have found a big problem with detection using:
IN FOREGROUND WORKS FINE
func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {}
The idea I want to implement is to manage on my own the time a beacon can be detected a second time, keeping me close to the beacon.
The problem is when try to detect the same beacon for second time (and sometimes even others for first time), for some strange reason this funcion is not called anymore, just after first detection.
The only way is remove battery from beacon (intermittent) or take my beacon and walk Until leaving the detection area (This always works).
for this last i'm using this function for verify:
func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {
if (state == CLRegionState.inside)
{
print("didDetermineState inside!!!!")
}
else if (state == CLRegionState.outside)
{
print("didDetermineState outside!!!!")
}
else
{
print("didDetermineState Other!!!!")
}
}
Only executing some of this 2 option, the function is fired again
Thanks in advance.
UPDATE
Considering this answer, didRangeBeacons
should be executed constantly, but i'm experimenting didEnterRegion
issue.
I'm using both functions:
- didRangeBeacons: for beacons visibles in ranging.
- didEnterRegion: for Geofencing and beacons too