Book Image

Learning iBeacon

By : Craig Gilchrist
Book Image

Learning iBeacon

By: Craig Gilchrist

Overview of this book

Table of Contents (16 chapters)
Learning iBeacon
About the Author
About the Reviewers

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: The proximity property gives you the distance from the device using the CLProximity enum, giving one of four values CLProximityUnknown, CLProximityFar, CLProximityNear, and CLProximityImmediate.

  • accuracy: The accuracy 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 visitor...