Search code examples
iosobjective-ccore-locationcllocationmanagergeofencing

Geofences Not Triggered By Walking Through Them


When a user terminates the app, I create a geofence around the user's last location, so that I can be notified when the user leaves that location.

CLRegion *workingGeoFence = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(lastLocation.coordinate.longitude, lastLocation.coordinate.latitude) radius:80.4672 identifier:@"centered"];


workingGeoFence.notifyOnExit = YES;
workingGeoFence.notifyOnEntry = NO;

[locationManager startMonitoringForRegion:workingGeoFence];

I'm calling the above method in response to this notification:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterTerminatedMode) name:UIApplicationWillTerminateNotification object:nil]; 

I then wait a few minutes, and walk directly out of the geofence, through the boundary and continue on straight... the geofence is never triggered.

This is for GPS only devices, FYI.

Since the geofence is being created in response to UIApplicationWillTerminateNotification, locationManager:didStartMonitoringForRegion: never has a chance to be called before the app terminates. But right after calling startMonitoringForRegion:, the geofence does appear in the monitoredRegions property.

Using always authorization, and successfully gathering locations in both foreground and background modes.

Might this have something to do with it?...

"Region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported."

More Failed Tests

concentric geofences I activated notify on entry and exit, then created concentric geofences (see image. I walked through each one, and once or twice stopped for a minute then proceeded on.

Then walked about a mile away, came back and walked into each one, back to the center.... and nothing. Note even a single trigger on entry or exit.

I just don't understand how these activities could not be covered under a geofence implementation..

I tried this with wifi on/off.

I also tried opening another app that gathers a GPS location upon boot. And still nothing triggered. I thought Apple shared these precise locations amongst all apps?

My guess is that they ONLY use a change of cell ID?

Not sure what else to possibly try.


Solution

  • the order is (lat, lon) NOT (lon, lat)!!!!!!