The iBeacon client side framework consists of two major components: detecting iBeacons and fetching iBeacons information from the server. Both functions are handled by the class ATGBeaconManager.
ATGBeacon
The class ATGBeacon
represents an iBeacon and encapsulates a Apple CLBeacon
class. This class has several properties that can be set directly using a CLBeacon
class and several properties that can only be set after fetching information from the server.
Source | Property | Description |
---|---|---|
Properties taken from | UUID | The unique identifier of the iBeacon, used to indicate the company to which the beacon belongs. |
major | The major number of the iBeacon, used to indicate the store to which the beacon belongs. | |
minor | the minor number of the iBeacon. We use this number to indicate the aisle or category that the beacon is in | |
accuracy | the distance of the iBeacon from the device in meters. If the number is less than 0, then the distance is either unknown or invalid | |
proximity - enum CLProximity | The following: | |
Properties fetched from the server | repositoryId | The repository id of the iBeacon. |
identifier | The iBeacon’s identifier. | |
enterAlerts | A list of | |
exitAlerts | A list of | |
store | The store where the iBeacon resides. | |
name | The name for the iBeacon. |
The methods isEqual
: and compare:
, which are part of a category called CLBeacon+ATGAdditions
, returns what is equal to another CLBeacon
if the UUID, major and minor values are the same. CLBeacon+ATGAdditions
also implements a hash function to hash all beacons with the same UUID, major and minor to the same values.
Detecting and Ranging iBeacons
The class ATGBeaconManager
makes use of Apple’s CoreLocation
Framework to monitor and range beacons. ATGBeaconManager
simplifies Apple’s framework by only needing UUID, Major and Minor to handle all iBeacon detection internally.. The manager is essentially a black box that removes the need to create any CLLocation
objects or worry about location managers, CLLocationManagerDelegates
etc.
ATGBeaconManager
provides several properties and methods and methods useful for working with iBeacons:
Type | Function/method | Description |
---|---|---|
Properties |
| Implements |
Required | didEnterStore: | Called when the UUID, major and minor combination for a detected beacon match a store. Passed an |
didExitStore: | Called when no beacons from the entered store have been ranged in a set timeout. Parameter is the | |
Methods | getBeaconEnterAlerts | Returns a list of |
getBeaconExitAlerts | Returns a list of | |
requestHelp:delegate | Invokes the | |
| Invokes the |
ATGBeaconManagerDelegate
provides delegate methods for both detecting and ranging beacons and for fetching beacon information. Detection methods are:
Method | Description |
---|---|
| A delegate method called when the |
| A delegate method called when the |
| A delegate method called when the device has ranged beacons inside of a particular region. Is passed a list of |
Fetching Beacon Information
ATGBeaconManager
also handles REST requests related to iBeacons. All REST methods call corresponding delegate methods on success or failure.
Supported REST calls include:
REST Call | Description |
---|---|
| Notifies the delegate of the UUIDs of beacons to should range. |
| Fetches |
| Notifies the delegate of the store what the UUID and major combination represent. |
| Populates the beacon parameter’s data by fetching it from the server. |
| Called when a beacon is first ranged. |
| Called after the store has been exited |
| Called when you have determined in which store the device is located. |
| Called when the user requests help. |
| Called to cancel help request. |
The ATGBeaconManager
handles all beacon detection internally and provides the methods listed in the previous section.