Inherits from NSObject
Declared in CCHSubscriptionService.h
CCHSubscriptionService.m

Overview

The subscription service is used tell ContextHub that you want to be notified when tagged elements are created, updated, and deleted on the server. You must enable push notifications if you want to receive updates from the server. When server changes are made, the device is notified using a background push notification. The subscription service will post notifications to the NSNotificationCenter when changes are detected.

Notifications

When you subscribe to tags, the following notifications are posted when tagged elements are created, updated, and deleted.

CCHBeaconCreatedNotification

the notification object is an NSDictionary representation of the beacon that was created. The userInfo object is not set.

CCHBeaconUpdatedNotification

the notification object is an NSDictionary representation of the beacon that was updated. The userInfo object is not set.

CCHBeaconDeletedNotification

the notification object is an id of the beacon that was deleted. The userInfo object is not set.

CCHGeofenceCreatedNotification

the notification object is an NSDictionary representation of the geofence that was created. The userInfo object is not set.

CCHGeofenceUpdatedNotification

the notification object is an NSDictionary representation of the geofence that was updated. The userInfo object is not set.

CCHGeofenceDeletedNotification

the notification object is an id of the geofence that was deleted. The userInfo object is not set.

CCHVaultItemCreatedNotification

the notification object is an NSDictionary representation of the vault item that was created. The userInfo object is not set.

CCHVaultItemUpdatedNotification

the notification object is an NSDictionary of representation of the vault item that was updated. The userInfo object is not set.

CCHVaultItemDeletedNotification

the notification object is an id of the vualt item that was deleted. The userInfo object is not set.

CCHDeviceCreatedNotification

the notification object is an NSDictionary representation of the device that was created. The userInfo object is not set.

CCHDeviceUpdatedNotification

the notification object is an NSDictionary of representation of the device that was updated. The userInfo object is not set.

CCHDeviceDeletedNotification

the notification object is an id of the device that was deleted. The userInfo object is not set.

Class Methods

sharedInstance

The singleton instance of the CCHSubscriptionService.

+ (instancetype)sharedInstance

Return Value

The singleton instance of the CCHSubscriptionService.

Declared In

CCHSubscriptionService.h

Instance Methods

addBeaconSubscriptionForTags:completionHandler:

Subscribes the device to beacon change notifications for the specified tags.

- (void)addBeaconSubscriptionForTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags.

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHSubscriptionService.h

addGeofenceSubscriptionForTags:completionHandler:

Subscribes the device to geofence change notifications for the specified tags.

- (void)addGeofenceSubscriptionForTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHSubscriptionService.h

addSubscriptionsForTags:options:completionHandler:

Subscribes the device to change notifications for the specified tags.

- (void)addSubscriptionsForTags:(NSArray *)tags options:(NSArray *)options completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags

options

(optional) an NSArray of the elements that you want to subscribe to. (CCHOptionBeacon, CCHOptionGeofence, CCHOptionVault, CCHOptionDevice)

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Discussion

Note: This will turn on background push notifications for all elements that have tags matching the tags array specified. You must enable push notifications, enbale remote notifications and background fetch capabilites, and you must call application:didReceiveRemoteNotification:completionHandler: on CCHPush.

Declared In

CCHSubscriptionService.h

getSubscriptionsWithCompletionHandler:

Gets all subscriptions for the current device.

- (void)getSubscriptionsWithCompletionHandler:(void ( ^ ) ( NSDictionary *subscriptions , NSError *error ))completionHandler

Parameters

completionHandler

executed when the request completes. The block is passed an NSDictionary of subscriptions. If an error occurs, the NSError will be passed to the block.

Discussion

Note: Access individual subscriptions using “BeaconSubscription” and “GeofenceSubscription” keys

Declared In

CCHSubscriptionService.h

removeBeaconSubscriptionForTags:completionHandler:

Unsubscribes the device from beacon change notifications for the specified tags.

- (void)removeBeaconSubscriptionForTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags.

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHSubscriptionService.h

removeGeofenceSubscriptionForTags:completionHandler:

Unubscribes the device from geofence change notifications for the specified tags.

- (void)removeGeofenceSubscriptionForTags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags.

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHSubscriptionService.h

removeSubscriptionsForTags:options:completionHandler:

Unsubscribes the device from change notifications for the specified tags.

- (void)removeSubscriptionsForTags:(NSArray *)tags options:(NSArray *)options completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

An NSArray of tags

options

(optional) an NSArray of the elements that you want to unsubscribe from. (CCHOptionBeacon, CCHOptionGeofence, CCHOptionVault, CCHOptionDevice)

completionHandler

(optional) Is executed when the request completes. If an error occurs, the NSError will be passed to the block.

Declared In

CCHSubscriptionService.h