Inherits from NSObject
Declared in CCHPush.h
CCHPush.m

Overview

The push service is used to register devices and to send push notifications with the ContextHub Push service.

The userInfo dictionary that is passed to the methods in this api can contain custom data and standard apple push notification properties. This implementation will pull out the apns and ContextHub keys and pass all other items as custom data.

   Keys
key value
alert the message you want sent
sound sound file you want played
content-available pass in a 1 if you want to deliver a push in the background
badge the number to be displayed on the icon
exclude_device_ids an array of the device ids that should be excluded
exclude_push_tokens an array of push tokens that should be excluded
mdm mobile device management key
priority can be either be set to 10 (immediate) or 5 (conserve power)
expiry identifies when a notification is no longer valid and can be discarded. The default is 1 day
category category for push
url_args sets the url arguments
collapse_key used to group messages on the Google Cloud Messaging service

Class Methods

sharedInstance

@ return The singleton instance of the CCHPush service.

+ (instancetype)sharedInstance

Declared In

CCHPush.h

Instance Methods

application:didReceiveRemoteNotification:completionHandler:

When contextual elements are changed, ContextHub will send background push notifications to the application letting you know that new content is available. This will allow the context events to update and stay in sync with the server.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo completionHandler:(void ( ^ ) ( enum UIBackgroundFetchResult result , CCHContextHubPush *contextHubPush ))completionHandler

Parameters

application

The UIApplication that received the remote notification.

userInfo

The NSDictionary that was delivered with the remote notification.

completionHandler

A completion block that is executed when the context sync is completed. The CCHContextHubPush BOOL indicates if the push notification was generated by ContextHub.

Declared In

CCHPush.h

registerDeviceToken:alias:tags:completionHandler:

Register a device for push notifications.

- (void)registerDeviceToken:(id)token alias:(NSString *)alias tags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

token

The device token.

alias

(optional) A string alias to associate with the device token. (pass nil to ignore value, @“” to remove current alias)

tags

(optional) An array of tags to associate with the token. (pass nil to ignore value, @[] to remove all current tags)

completionHandler

(optional) returns nil if succeeded otherwise includes an error object.

Declared In

CCHPush.h

sendNotificationToAliases:userInfo:completionHandler:

Send Push Notification to aliases.

- (void)sendNotificationToAliases:(NSArray *)aliases userInfo:(NSDictionary *)userInfo completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

aliases

The aliases to notify.

userInfo

The data to be sent in the notification. Exclude devices by passing an array of device IDs in the @“exclude_device_ids” key.

completionHandler

Completion block. If an error occurs an NSError will be passed to the block.

Declared In

CCHPush.h

sendNotificationToDevices:userInfo:completionHandler:

Send Push Notifications to devices.

- (void)sendNotificationToDevices:(NSArray *)devices userInfo:(NSDictionary *)userInfo completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

devices

The device ids to notify.

userInfo

The data to be sent in the notification.

completionHandler

Completion block. If an error occurs an NSError will be passed to the block.

Declared In

CCHPush.h

sendNotificationToTags:operator:userInfo:completionHandler:

Send Push Notification to tags.

- (void)sendNotificationToTags:(NSArray *)tags operator:(NSString *)tagOperator userInfo:(NSDictionary *)userInfo completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

The tags to notify.

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.

userInfo

The data to be sent in the notification. Exclude devices by passing an array of device IDs in the @“exclude_device_ids” key.

completionHandler

Completion block. If an error occurs an NSError will be passed to the block.

Declared In

CCHPush.h

sendNotificationToTags:userInfo:completionHandler:

Send Push Notification to tags.

- (void)sendNotificationToTags:(NSArray *)tags userInfo:(NSDictionary *)userInfo completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

tags

The tags to notify.

userInfo

The data to be sent in the notification. Exclude devices by passing an array of device IDs in the @“exclude_device_ids” key.

completionHandler

Completion block. If an error occurs an NSError will be passed to the block.

Declared In

CCHPush.h

updateAlias:tags:completionHandler:

Update a device’s alias and tags.

- (void)updateAlias:(NSString *)alias tags:(NSArray *)tags completionHandler:(void ( ^ ) ( NSError *error ))completionHandler

Parameters

alias

(optional) A string alias to associate with the device token. (pass “nil” to ignore value, @“” to remove current alias)

tags

(optional) An array of tags to associate with the token. (pass nil to ignore value, @[] to remove all current tags)

completionHandler

(optional) returns nil if succeeded otherwise includes an error object.

Declared In

CCHPush.h