Understanding distance
When we range beacons using the locationManager:didRangeBeacons:inRegion
method of CLLocationManager
, we're given a collection of beacons (CLBeacon
). In order to understand the distance of the beacon from our device, the CLBeacon
class gives us two properties:
proximity
: Theproximity
property gives you the distance from the device using theCLProximity
enum, giving one of four valuesCLProximityUnknown
,CLProximityFar
,CLProximityNear
, andCLProximityImmediate
.accuracy
: Theaccuracy
property gives you the distance from the device as a double value, which is the distance measured in meters. If the distance cannot be determined, the value is returned as negative.
The CLProximity
enum values represent the approximate distance from the device in four bands and are great to determine when to perform an action.
Imagine you're building an app for a museum. Your app tells users about the individual cabinets within different exhibits as visitors walk through. If your...