Inherits from NSObject
Declared in CCHDevice.h
CCHDevice.m

Overview

The CCHDevice class is used work with devices.

Structure of device NSDictionary

key value
additional_info NSDictionary of device specific information (not always present)
alias alias that is set for the device (not always present)
device_type describes the device, often pulled for the user agent
id database id for the device
last_profile NSDictionary of contextual information from the last time the device was seen by the server
push_token push token assigned to the device (not always present)
tag_string a comma separated string of the tags associated with the device
tags NSArray of tags associated with the device

Class Methods

sharedInstance

The singleton instance of CCHDevice.

+ (instancetype)sharedInstance

Return Value

The singleton instance of CCHDevice.

Declared In

CCHDevice.h

Instance Methods

deviceId

The vendor device id as UUIDString.

- (NSString *)deviceId

Return Value

The vendor device id as UUIDString.

Declared In

CCHDevice.h

getDeviceWithId:completionHandler:

Gets a device from ContextHub using the device Id.

- (void)getDeviceWithId:(NSString *)deviceId completionHandler:(void ( ^ ) ( NSDictionary *device , NSError *error ))completionHandler

Parameters

deviceId

The id of the device stored in ContextHub.

completionHandler

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

Declared In

CCHDevice.h

getDevicesWithAlias:completionHandler:

Gets devices from ContextHub using the device alias.

- (void)getDevicesWithAlias:(NSString *)alias completionHandler:(void ( ^ ) ( NSArray *devices , NSError *error ))completionHandler

Parameters

alias

The alias associated with the devices that you are interested in.

completionHandler

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

Declared In

CCHDevice.h

getDevicesWithTags:completionHandler:

Gets devices from ContextHub using tags.

- (void)getDevicesWithTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSArray *devices , NSError *error ))completionHandler

Parameters

tags

Tags of the devices that you are interested in.

completionHandler

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

Declared In

CCHDevice.h

getDevicesWithTags:operator:completionHandler:

Gets devices from ContextHub using tags.

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

Parameters

tags

Tags of the devices that you are interested in.

tagOperator

(optional) Operator used to build the query with the tags. Passing ANY will find all devices that match any of the tags. Passing ALL will find devices 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 the devices. If an error occurs, the NSError will be passed to the block.

Declared In

CCHDevice.h

getDevicesWithTags:operator:location:radius:completionHandler:

Gets devices from ContextHub using tags and location information.

- (void)getDevicesWithTags:(NSArray *)tags operator:(NSString *)tagOperator location:(CLLocation *)location radius:(CLLocationDistance)radius completionHandler:(void ( ^ ) ( NSArray *devices , NSError *error ))completionHandler

Parameters

tags

Tags of the devices that you are interested in. Passing nil will return devices without tags.

tagOperator

(optional) Operator used to build the query with the tags. Passing ANY will find all devices 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.

location

(optional) Location is used to filter the results. Passing nil will remove the location filter.

radius

Radius in meters around the location which ContextHub considers “nearby”. Passing 0 will use the default radius of 50 miles (80437 meters). If the location parameter is nil, the radius parameter is ignored.

completionHandler

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

Declared In

CCHDevice.h

setDeviceAlias:tags:completionHandler:

Updates the device record on contexthub.

- (void)setDeviceAlias:(NSString *)alias tags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSDictionary *device , NSError *error ))completionHandler

Parameters

alias

(optional) The alias associated with the device.

tags

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

completionHandler

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

Discussion

Note: This method updates the data for the current device. The tags and alias that are set here can be used with CCHPush. The tags can also be used with the CCHSubscriptionService. This method gathers meta-data about the device and sends it to ContextHub along with the alias and tags. You can call this method multiple times.

Declared In

CCHDevice.h