iBeacons Topic Guide

What is iBeacon?

iBeacon is a new technology that extends Location Services in iOS by monitoring for proximity to a new class of Bluetooth-powered transmitters that emit information about their presence. Any compatible iOS device with iOS 7 or later, Bluetooth enabled, and Location Services opted in can receive the information and take action based on this transmission. For more detail about device compatibility, please see iOS: Understanding Beacon.

Region Monitoring

It’s important to consider the differences between a geographical region and a beacon region when it comes to iOS. Since iBeacon uses iOS’s Core Location Framework, there are a number of similarities between geographical and beacon regions in terms of app implementation, e.g., the concept of monitoring for entry and exit to and from a region or location.

The difference is that location events triggered by an iBeacon represent relative proximity to the transmitting device, as distinct to the entry or exit from a physical region as defined by GPS.

For more information about Region Monitoring in iOS, please see: Region Monitoring and iBeacon.

Urban Airship and iBeacons

In order to send notifications or perform other actions based on a user’s interaction with/proximity to an iBeacon, simply add or remove Tags upon entry or exit from the iBeacon region. Depending on your strategy for tagging devices and messaging or performing other actions based on the associated metadata, you might choose to add a particular tag upon entry and remove it upon exit, or you might only wish to add tags and never remove them, e.g., "has_been_here_once" , "has_been_here_twice", etc.

If a tag already exists for a device, any request to add the same tag to that device will be ignored. Therefore, it is a best practice to always remove tags upon exit if you wish to look for a tag_added trigger in the future.

For more information about creating and tracking Automated Messages, see Automation API Reference and the Automation Composer.

iBeacon Technical Basics

iBeacons work with Bluetooth Low Energy (BLE), also known as Bluetooth Smart. BLE is a low-powered variation of Bluetooth that works with Bluetooth 4.0 devices and has a very low impact on battery life. Thus, closed apps can still listen for iBeacons while running in the background.

Each iBeacon has a unique UUID - Universally Unique Identifier. When an app enters or exists the proximity range of a specific UUID, a listening app can be notified. This notification usually takes place in the form of a tag. For example: An app detects the UUID of particular iBeacon and sets a tag called in_store. in_store being set then triggers a push notification which is received on that particular device. The user experiences this as seeing a timely notification as they enter the store.

Apps can only listen for UUIDs which have been provided to the app explicitly; they cannot listen for any UUID which may be present. Additionally, there are two other values which a developer may use to name and track iBeacons:

  • Major Value - represents any ‘gross location’ identification

  • Minor Value - names a more precise location within a particular location instance

For example: Company X may have 500 national stores with 15 departments within each store. The NYC store may have Major Value = 2; the shoe department might be indicated by Minor Value = 7.

Sample Client Code

In the following iOS example, we see how to add and remove tags via the location manager callback.

#import <CoreLocation/CoreLocation.h>
#import "UAirship.h"
#import "UAPush.h"

// CLLocationManagerDelegate protocol implementation

// On Beacon Region Entry
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {

    UA_LDEBUG(@"Beacon Monitor: didEnterRegion '%@'", region.identifier);

    // Add 'entered_region_<ID> tag and remove 'exited_region_<ID>' tag (if necessary).
    // These tags are useful for automation events.
    [[UAirship push] removeTag:[NSString stringWithFormat:@"exited_region_%@", region.identifier]];
    [[UAirship push] addTag:[NSString stringWithFormat:@"entered_region_%@", region.identifier]];

    // Add a 'has_seen_beacon_<ID>' tag. This is useful for creating segments of users
    // who have ever visited a particular beacon.
    [[UAirship push] addTag:[NSString stringWithFormat:@"has_seen_beacon_%@", region.identifier]];

    [[UAirship push] updateRegistration];

}

// On Beacon Region Exit
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {

    UA_LDEBUG(@"Beacon Monitor: didExitRegion '%@'", region.identifier);

    // Add 'exited_region_<ID> tag and remove 'entered_region_<ID>' tag.
    // These tags are useful for automation events.
    [[UAirship push] addTag:[NSString stringWithFormat:@"exited_region_%@", region.identifier]];
    [[UAirship push] removeTag:[NSString stringWithFormat:@"entered_region_%@", region.identifier]];

    [[UAirship push] updateRegistration];

}

Associate an Apple Wallet Pass with a Beacon

If you are an Urban Airship Reach customer, you may wish to associate an Apple Wallet pass with a beacon. See the Reach - Create Pass reference for details.