Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone - Doubts on geofencing

I've heard of geofencing and I have some doubts. Hope you can answer some of them.

-It's new for iOS 5.1 but what is the difference between geofencing and Using Regions? From what I've read is nearly the same, the battery drain?

-Why can't I find apple documentation on geofencing?

-How do you define the regions? can I add them remotely, via webservice?

Thanks.

like image 615
subharb Avatar asked Mar 31 '12 11:03

subharb


People also ask

How accurate is geofence?

App Developers can use native Android and iOS location detection to power their location-based experiences and engagement. However, native geofencing technology can only deliver accuracy of around 100-200 meters. For context, that's about the length of a soccer field.

Does geofencing use battery iPhone?

Myth #2: Geofencing Drains The Mobile Phone Battery Some geofencing providers use GPS for geofencing, which does have the effect of draining smartphone batteries faster. At Plot Projects, because we use cellular and Wi-Fi technology, this is not the case.

What does geofencing mean on iPhone?

Geofencing is a technology that uses location information from a smart device—like GPS, RFID, or Wi-Fi—to track whether a device is inside or outside a “fence,” a virtual boundary around an area in the real world. The technology is used for a variety of purposes, like security, location tracking, and advertising.

Does geofencing work if location is off?

Even with your location tracking turned off, a geofence can still establish your general location through your device's unique IP address.


2 Answers

Geofencing has actually been around since iOS 4. You can find documentation on it in the Apple Location Awareness Programming Guide. It is also referred to as "region monitoring".

The regions are pretty simple to use. Create a CLRegion with the center point (lat, long), radius, and a unique identifier. Then call the -startMonitoringForRegion. Granted you will need to register a CLLocationManagerDelegate to listen for the callbacks, -didEnterRegion and -didExitRegion, but that is pretty easy to do as well.

You can't add them remotely. Only from the device. I have learned a few things about them over the last couple years. So hopefully this will save you some trouble down the road.

  • Not all devices can monitor regions, so make sure you check for availability
  • There is a min and max region size. If you register a region over or under those values, it will default to the min/max. The min is 100M, max is something like 1/3 the size of the globe. Pretty large.
  • There is a max number of regions 1 device can monitor. This "pool" of regions is shared by all apps, and older fences will get purged to make room for newer fences. So be prepared for that. The max number is close to 100. But shared between passbook apps, reminders, and other apps... can get burned up pretty quick.
  • Make sure you only have one instance of your location manager delegate, multiple instances will get you multiple delegate calls, they are all listening.

Geofences are a great way to add functionality to locations without any of the overhead active GPS and location tracking has. In my experience, geofences pose no noticeable battery drain when leaving on all the time. Apple has them figured out pretty well. They don't carry the same accuracy as active GPS, but they are close enough. Good luck.

UPDATE Some of the information here is a bit dated now. The number of regions you can monitor is now 20 and is capped per app. Also, the minimum size is not 100M, it can be smaller, but accuracy is not guaranteed at lower numbers.

like image 77
Bill Burgess Avatar answered Oct 04 '22 00:10

Bill Burgess


"Geofencing" has always been around, since iOS 4 in the form of "Region monitoring". It uses distance checking to see if you've entered a circle. This is not true geofencing, as true geofencing is checking if a point lands in a polygon (called point in polygon).

As of iOS 6, there is currently nothing akin to region monitoring that uses point in polygon. To do true geofencing, you would have to use a combination of Region monitoring and GPS. There is no Apple documentation for geofencing because CoreLocation doesn't support it.

If you are going to take the point-in-poly approach, I would recommend ray casting. There is an Objective-C class that implements it really well. It's called objc-BorderPatrol.

As for sending fences from a web service, it may be possible to do something similar to Twitter's streaming API, but that may be too intensive. It's better to use Significant Location to update your fences. If you're going to send fences from a web service, I would recommend using MySQL or PostGRE SQL as both have really good geospatial extensions.

A few caveats: -> -[CLRegion containsCoordinate:] is never called by any CoreLocation object. All of the distance checking is internal. -> Significant Location updates every 500m or 5 minutes, whichever comes first. Significant location uses the IP address from a cell tower to determine location. -> Geofences and regions can overlap, keep track of this.

like image 28
Nate Symer Avatar answered Oct 04 '22 00:10

Nate Symer