Inherits from NSObject
Declared in CCHBeaconService.h
CCHBeaconService.m

Overview

The Beacon Service is used to create, read, update, and delete beacons on ContextHub.

Structure of the beacon NSDictionary

key value
id unique id of the beacon on the ContextHub server
name name of the beacon
uuid UUID of the beacon
major major value of the beacon
minor minor value of the beacon
tags NSArray of tags associated with the beacon

Class Methods

regionForBeacon:

Creates a CLBeaconRegion from a beacon dictionary.

+ (CLBeaconRegion *)regionForBeacon:(NSDictionary *)beacon

Parameters

beacon

NSDictionary that contains beacon information.

Return Value

A CLBeaconRegion from a beacon dictionary.

Discussion

Note: This is intended to be used with the beacons that are returned in the CCHBeaconService.

Declared In

CCHBeaconService.h

sharedInstance

The singleton instance of the CCHBeaconService.

+ (instancetype)sharedInstance

Return Value

The singleton instance of the CCHBeaconService.

Declared In

CCHBeaconService.h

Instance Methods

createBeaconWithProximityUUID:major:minor:name:tags:completionHandler:

Creates a new beacon on the ContextHub server.

- (void)createBeaconWithProximityUUID:(NSUUID *)proximityUUID major:(CLBeaconMajorValue)major minor:(CLBeaconMinorValue)minor name:(NSString *)name tags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSDictionary *beacon , NSError *error ))completionHandler

Parameters

proximityUUID

The uuid for the iBeacon.

major

(optional) The major value for the iBeacon.

minor

(optional) The minor value for the iBeacon.

name

The name of the iBeacon.

tags

(optional) The tags to be applied to the beacon.

completionHandler

(optional) Called when the request completes. The block is passed an NSDictionary object that represents the beacon. If an error occurs, the NSError will be passed to the block.

Discussion

Note: Tags are used to filter beacons and are used by the CCHSubscriptionService.

Declared In

CCHBeaconService.h

deleteBeacon:completionHandler:

Deletes an existing beacon from ContextHub.

- (void)deleteBeacon:(NSDictionary *)beacon completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

beacon

The beacon to be deleted from ContextHub.

completionHandler

Called when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHBeaconService.h

getBeaconWithId:completionHandler:

Gets a beacon from ContextHub using the beacon Id.

- (void)getBeaconWithId:(NSString *)beaconId completionHandler:(void ( ^ ) ( NSDictionary *beacon , NSError *error ))completionHandler

Parameters

beaconId

The id of the beacon stored in ContextHub.

completionHandler

Called when the request completes. The block is passed an NSDictionary object that represents the beacon. If an error occurs, the NSError will be passed to the block.

Declared In

CCHBeaconService.h

getBeaconsWithTags:completionHandler:

Gets beacons from the ContextHub server.

- (void)getBeaconsWithTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSArray *beacons , NSError *error ))completionHandler

Parameters

tags

(optional) Tags of the beacons that you are interested in. Passing nil will return beacons without tags.

completionHandler

Called when the request completes. The block is passed an NSArray of NSDictionary objects that represent iBeacons. If an error occurs, the NSError will be passed to the block.

Declared In

CCHBeaconService.h

getBeaconsWithTags:operator:completionHandler:

Gets beacons from the ContextHub server.

- (void)getBeaconsWithTags:(NSArray *)tags operator:(NSString *)tagOperator completionHandler:(void ( ^ ) ( NSArray *beacons , NSError *error ))completionHandler

Parameters

tags

(optional) Tags of the beacons that you are interested in. Passing nil will return beacons without tags.

tagOperator

(optional) Operator used to build the query with the tags. Passing ANY will find all geofences that match any of the tags. Passing ALL will find geofences that have all of the tags provided. Passing nil will use the default ALL operator.

completionHandler

Called when the request completes. The block is passed an NSArray of NSDictionary objects that represent iBeacons. If an error occurs, the NSError will be passed to the block.

Declared In

CCHBeaconService.h

updateBeacon:completionHandler:

Updates a beacon on the ContextHub server.

- (void)updateBeacon:(NSDictionary *)beacon completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

beacon

The beacon to be updated on ContextHub.

completionHandler

Called when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHBeaconService.h