Utilizing iBeacon Data in an App

Trey Baugher
iOS App Development
3 min readDec 1, 2014

--

NOTE: This article is a continuation of another. Click the Medium article link below to start from the beginning.

Making an iBeacon app

Local Notifications

Most people only think of location specific notifications when it comes to iBeacon apps. These local notifications are just the tip of the iceberg.

I find these sort of notifications are easy to overuse and abuse leading to an annoying user experience. We decided to stay away from them almost altogether in the app. The app only sends two notifications to users through out their entire experience. Once on their first visit to Manifest’s office to welcome them. The other is sent to thank them for visiting after they have left for the first time.

It’s rather easy to setup notifications to trigger when an app encounters an iBeacon. Apple’s CLBeacon model, is what apps use to represent an iBeacon. CLBeacon has a notification property built right into it, allowing for easy notification triggering.

Monitoring vs. Ranging

Apps receive iBeacon location data by registering for monitoring and/or ranging. The first time an iBeacon app opens it registers with the iPhone to “Monitor” for specific iBeacons. The app is then notified each time the iPhone enters or leaves that iBeacon’s region. Depending on the app’s location permissions, these events can be sent to the app even if it is not open.

Ranging can only happen when the app is active. With ranging on the app has access to the estimated distance between the iPhone each beacon it is in range of. This is the real power of iBeacons. With ranging on it’s possible to know a user’s location down to the foot. You can triangulate their position using the distance from multiple beacons in an area. While ranging is useful it is also very battery intensive, so it should be used sparingly. If over-used, the battery drain could cause the user to completely turn off location services for the app. This should be avoided as a permissions denial would render most location apps useless.

In the Manifest app we avoid iBeacon ranging altogether. Instead we rely on the much more battery efficient monitoring. The app records and saves the latest time and date of each iBeacon region’s entry and exit event. By saving region event timestamps the app can compare entry and exit events to see which is the latest. If they’re entry event is more recent than their exit event then we know they are currently in that region. The app saves the timestamps to the device as soon as the event occurs. Even if the app isn’t open when an event happens it is still recorded and available for reference later on.

iBeacon Weaknesses

iBeacon technology like everything else, has it’s faults. An iPhone, iPad or even a mac computer can be configured to imitate any iBeacon. Someone could easily fool an app into thinking they’re in an area when they aren’t. Luckily you can detect this trick using GPS monitoring. Just check the iPhone’s GPS position when an iBeacon related location event triggers. This will ensure that the iPhone is in the general area of the iBeacon, meaning ing the event is valid.

The iPhone will also occasionally lose an iBeacon’s signal while still in range. This triggers subsequent false exit and re-entry events. The iPhone delays exit events in an attempt to avoid this issue but false exits do still happen.

That’s it for this topic. Use one of the 2 Medium article links below to learn more about iBeacon apps.

--

--