Setting up geofences
Sometimes, your app doesn't really need to know the details of the user's whereabouts. Sometimes, you're only interested in tracking whether the user has exited or left a certain area, in order to show certain content in your app or to unlock some kind of special feature. Core Location has great support for monitoring geofences. A geofence is a certain area that is defined using a certain GPS coordinate and a circular radius around this point. In Core Location, geofences are set up using CLRegion
subclasses. Core Location provides two different region types that you can use:
CLCircularRegion
CLBeaconRegion
A CLCircularRegion
type is used to set up a geofence, as described before. A CLBeaconRegion
type is used with physical BLE iBeacons, and essentially provides geofencing in a very small radius, for instance, just a couple of meters. In this section, you will learn how to set up a CLCircularRegion
type that is set up around a user...