Geofencing does exist with iOS 4. You can find the documentation on it in the Apple Location Awareness Guide . It is also referred to as "region monitoring."
The regions are pretty easy to use. Create a CLRegion with a center point (lat, long), radius and unique identifier. Then call -startMonitoringForRegion . Of course, you will need to register CLLocationManagerDelegate to listen for callbacks, -didEnterRegion and -didExitRegion , but this is also very easy to do.
You cannot add them remotely. Only from the device. Over the past couple of years, I learned a few things about them. Therefore, I hope this will save you from any problems in the future.
- Not all devices can control regions, so make sure you check for availability.
- Area size min and max. If you register an area above or below these values, it will default to min / max. The minimum value is 100 m, the maximum value is 1/3 of the size of the globe. Pretty big.
- The maximum number of regions can be controlled by 1 device. This βpoolβ of regions is shared by all applications, and old fences will be cleared to make room for new fences. So be prepared for this. The maximum number is close to 100. But sharing between apps with passwords, reminders and other apps ... can burn out quickly.
- Make sure that you have only one instance of your location manager delegate, multiple instances will receive you several delegate calls, they are all listening.
Geofences is a great way to add functionality to locations without any active active GPS and location tracking. In my experience, geofences do not leave a noticeable battery drain when leaving all the time. Apple understood them very well. They do not carry the same accuracy as active GPS, but they are close enough. Good luck.
UPDATE Some information here is a bit outdated. The number of regions that you can control is now 20 and is limited for each application. In addition, the minimum size is not 100M, it may be smaller, but accuracy is not guaranteed at lower values.
Bill burgess
source share