Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Geofencing with WiFi turned off

I have code that creates a geofence on my iPhone that will trigger some code to be executed when didExitRegion gets called. However, I have found that when I have WiFi switched off that didExitRegion never gets triggered. Is WiFi required for monitoring region changes on iOS? My desired accuracy is set to kCLLocationAccuracyHundredMeters. I am testing on iOS 6.1 and iPhone 4.

Here is my code for setting up location monitoring:

- (id)init {
self = [super init];
if (self) {
    CLLocationManager *manager = [[CLLocationManager alloc] init];
    manager.delegate = self;
    manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    manager.distanceFilter = RADIUS/10.0;
    manager.headingFilter = kCLHeadingFilterNone;
    self.locationManager = manager;
    self.authorizationStatus = [CLLocationManager authorizationStatus];
}
return self;
}

Thanks

like image 285
Brian Boyle Avatar asked Apr 08 '13 16:04

Brian Boyle


People also ask

How does geofencing work on iOS?

Geofencing notifies your app when its device enters or leaves geographical regions you set up. It lets you make cool apps that can trigger a notification whenever you leave home, or greet users with the latest and greatest deals whenever favorite shops are nearby.

How do I turn on geofencing on my iPhone?

Setting up geofencing on an iPhone (iOS)Turn on Geofencing in the Home Center app (Application Settings > Geofencing). Go to the iPhone's Settings, scroll down and choose Home Center from the list. Tap Location and set Always (and make sure you have Precise Location enabled). Done.

How do I turn off my wifi location?

You can control what location information your phone can use. Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.


2 Answers

iOS devices use three methods to discover user location. From (usually) most accurate to least accurate they are:

  1. GPS hardware
  2. By identifying nearby wifi networks
  3. Cell Tower Triangulation

If your app doesn't use GPS or is not running (ie. has previously been terminated), the device will attempt to use methods 2 and 3 above to locate the user. So the device's ability to locate the user (when the GPS hardware is not in use or there is a weak GPS signal) depends on the availability of wifi networks and cell towers. The more wifi networks and cell towers, the better the location accuracy. Therefore, when a user enters or exits a monitored region (ie. crosses a "geofence"), it is impossible to predict exactly when the user will receive the notification if at all. (Of course, if the region in question is always the same, the device will more or less locate the user with the same degree of accuracy on each occasion).

Here's the relevant documentation from the Location Awareness Programming Guide:

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.

So, wifi is not required for region monitoring to work, but with it enabled, your device will have a better chance in determining whether or not the user has crossed a region's geofence.

like image 184
gavdotnet Avatar answered Oct 06 '22 21:10

gavdotnet


If you turn off WiFi, your location accuracy lowers. If you don't have GPS signal(inside some buildings), you will not get any location updates. Have you tried this when you are outside, or if you used the location simulator to test?

Also, WiFI is not required for geofence function if you have GPS(iPhones or iPad with sims).

like image 22
mskw Avatar answered Oct 06 '22 19:10

mskw