Messaging
This interface enables publication and receipt of Real-Time Messages and Push Notifications.
This interface has the following classes:
- ICAppDelegate
- ICMessaging
- ICMessagingActionsDelegate
- ICMessagingDelegate
- ICDeviceTokenDelegate
- ICInAppDisplay
- ICMessage
- ICTopic
- ICThread
- ICMessageData
- ICMessageStore
- ICDefaultMessageStore
- ICInteractiveData
- ICFormField
ICAppDelegate
This class is mandatory to use push notifications.
applicationDidEnterBackground
This method is used to disconnects the RTM connection when the app enters background mode.
Syntax: (void)applicationDidEnterBackground:(UIApplication *)application;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Do something...
[super applicationDidEnterBackground:application];
// Do something...
}
@end
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Do something...
[self.icAppDelegate applicationDidEnterBackground:application];
// Do something...
}
@end
applicationWillEnterForeground
This method is used to reconnects the RTM connection when the app enters foreground mode.
Syntax: - (void)applicationWillEnterForeground:(UIApplication *)application;
Example:
// AppDelegate.h@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>@end
// AppDelegate.m@implementation AppDelegate
-(void)applicationWillEnterForeground:(UIApplication *)application
{
// Do something...
[super applicationWillEnterForeground:application];
// Do something...
}
@end
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
-(void)applicationWillEnterForeground:(UIApplication *)application
{
// Do something...
[self.icAppDelegate applicationWillEnterForeground:application];
// Do something...
}
@end
didReceiveNotificationResponse
This method is used to handle the notification response when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction.
Syntax: - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler;
Example:
// AppDelegate.h@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>@end
// AppDelegate.m@implementation AppDelegate
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
// Do something...
[super userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
// Do something...
}
@end
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
// Do something...
[self.icAppDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
// Do something...
}
@end
willPresentNotification
This method is used to handle the notification received when application is in the foreground.
Syntax: - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler;
Example:
// AppDelegate.h@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>@end
// AppDelegate.m@implementation AppDelegate
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
// Do something...
[super userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
// Do something...
}
@end
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
// Do something...
[self.icAppDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
// Do something...
}
@end
didFinishLaunchingWithOptions
This method is used to initialize the SDK. It reads the configuration from the IMIconnectConfiguration.plist
file. If the app is allowed to use push notifications, it will register the app for push notifications.
Syntax: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Do something...
[super application:application didFinishLaunchingWithOptions:launchOptions];
// Do something...
return YES;
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Do something...
[self.icAppDelegate application:application didFinishLaunchingWithOptions:launchOptions];
// Do something...
return YES;
}
didRegisterUserNotificationSettings
This method is used to register the app for push notifications if the app is allowed to use it.
Syntax: - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
// Do something...
[super application:application didRegisterUserNotificationSettings:notificationSettings];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
// Do something...
[self.icAppDelegate application:application didRegisterUserNotificationSettings:notificationSettings];
// Do something...
}
handleActionWithIdentifier for LocalNotifications
This method is used to handle the action sent by a local notification and selected by the user then it will send a read receipt to the back end. This feature will work only if the app is allowed to use either Push or Live Chat / In-App Messaging.
Syntax:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
{
// Do something...
[super application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
{
// Do something...
[self.icAppDelegate application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler];
// Do something...
}
handleActionWithIdentifier forLocalNotification withResponseInfo
This method is used to handle the action sent by a local notification and selected by the user then it will send a read receipt to the back end. You can pass additional details through the responseInfo dictionary. This feature will work only if the app is allowed to use either Push or RTM.
Syntax:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[super application:application handleActionWithIdentifier:identifier forLocalNotification:notification withResponseInfo:responseInfo completionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[self.icAppDelegate application:application handleActionWithIdentifier:identifier forLocalNotification:notification withResponseInfo:responseInfo completionHandler:completionHandler];
// Do something...
}
handleActionWithIdentifier forRemoteNotification
This method is used to handle the action sent by a remote notification and selected by the user then it will send a read receipt to the back end. This feature will work only if the app is allowed to use Push.
Syntax:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[super application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo completionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[self.icAppDelegate application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo completionHandler:completionHandler];
// Do something...
}
handleActionWithIdentifier forRemoteNotification withResponseInfo
This method is used to handle the action sent by a remote notification and selected by the user then it will send a read receipt to the back end. You can pass additional details through the responseInfo dictionary. This feature will work only if the app is allowed to use Push.
Syntax:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler;
.
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[super application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo withResponseInfo:responseInfo completionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler
{
// Do something...
[self.icAppDelegate application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo withResponseInfo:responseInfo completionHandler:completionHandler];
// Do something...
}
didRegisterForRemoteNotificationsWithDeviceToken
This method is used to send the device token to the back end in order to be used to send push notification to the user.
Syntax: - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Do something...
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Do something...
[self.icAppDelegate application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
// Do something...
}
didFailToRegisterForRemoteNotificationsWithError
This method is used to log the reason why the app has failed to register for push notification.
Syntax: - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
// Do something...
[super application:application didFailToRegisterForRemoteNotificationsWithError:error];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
// Do something...
[self.icAppDelegate application:application didFailToRegisterForRemoteNotificationsWithError:error];
// Do something...
}
didReceiveRemoteNotification
This method is used to handle the received remote notification. Using this method a notification can be sent to the user or to notify the app with changes done on Webex Connect. A delivery report will be sent to the back end.
It is recommended to use the method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
instead of this method. This method will not be invoked when you implement - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
.
Syntax: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
didReceiveRemoteNotification with fetchCompletionHandler
This method is used to handle the received remote notification. Using this method a notification can be sent to the user or to notify the app with changes done on Webex Connect.
Syntax: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
// Do something...
[super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate ()
@property (nonatomic) ICAppDelegate *icAppDelegate;
@end
@implementation AppDelegate
- (ICAppDelegate *)icAppDelegate
{
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
// Do something...
[self.icAppDelegate application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
// Do something...
}
didReceiveLocalNotification
This method is used to handle the received local notification.
Syntax: - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification;
{
// Do something...
[super application:application didReceiveLocalNotification:notification];
// Do something...
}
// AppDelegate.m
@interface AppDelegate()
@property(nonatomic) ICAppDelegate * icAppDelegate;
@end
@implementation AppDelegate
-
(ICAppDelegate * ) icAppDelegate {
if (_icAppDelegate != nil) {
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
-
(void) application: (UIApplication * ) application didReceiveLocalNotification: (UILocalNotification * ) notification; {
// Do something...
[self.icAppDelegate application: application didReceiveLocalNotification: notification];
// Do something...
}
performFetchWithCompletionHandler
This method is used to launch the monitoring process and retrieve pending messages. If new messages are available, a local notification is sent to the user.
Syntax: - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
Example:
// AppDelegate.h
@interface AppDelegate : ICAppDelegate <UIApplicationDelegate>
@end
// AppDelegate.m
@implementation AppDelegate
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
// Do something...
[super application:application performFetchWithCompletionHandler:completionHandler];
// Do something...
}
// AppDelegate.m
@interface AppDelegate()
@property(nonatomic) ICAppDelegate * icAppDelegate;
@end
@implementation AppDelegate
-(ICAppDelegate * ) icAppDelegate {
if (_icAppDelegate != nil)
{
return _icAppDelegate;
}
_icAppDelegate = [ICAppDelegate new];
return _icAppDelegate;
}
-(void) application: (UIApplication * ) application performFetchWithCompletionHandler: (void( ^ )(UIBackgroundFetchResult)) completionHandler {
// Do something...
[self.icAppDelegate application: application performFetchWithCompletionHandler: completionHandler];
// Do something...
}
ICMessaging
The ICMessaging singleton class facilitates the ability to send and receive RTM messages and update the read status for RTM and Push.
Property | Description |
---|---|
@property (nonatomic, weak) id delegate; | This property refers to the delegate implementing ICMessagingDelegate methods. |
@property (nonatomic, weak) id actionsDelegate; | This property refers to the delegate implementing ICMessagingActionsDelegate methods. |
@property (nonatomic, readonly) BOOL isConnected; | This property returns YES if the RTM connection is currently connected. |
@property (nonatomic, readonly) ICConnectionStatus connectionStatus; | This property returns the current connection status between the SDK and the Webex Connect platform. |
@property (nonatomic) id messageStore | The ICMessageStore implementation which the SDK will use to store data. Passing a null value is valid and disables storage capability. |
@property (nonatomic, weak) id tokenDelegate; | This property refers to the delegate implementing ICDeviceTokenDelegate methods. |
- (void)sendClickedEventForTransactionId:(NSString *)transactionId forButton:(ICButton *)button completionHandler:(void(^)(NSError *error))completionHandler;
This method sends a click event to the messaging manager for the selected button and with the transaction id.
Syntax: - (void)sendClickedEventForTransactionId:(NSString *)transactionId forButton:(ICButton *)button completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
transactionId | NSString | The transactionId of the message |
button | ICButton | The interacted ICButton for which an ICMessage is created |
Return Value: nil
Sample Code:
[[ICMessaging shared] sendClickedEventForTransactionId:_message.transactionId forButton:_buttonObj completionHandler:^(NSError *error) {
NSLog(@"sendClickEvent ICInteractiveDataTypeWebURL error:%@",error);
}];
shared
This method is returns the ICMessaging
singleton instance. The instance is created internally on demand.
Syntax: + (instancetype)shared;
Return Value: Returns ICMessaging
singleton instance.
connect
Once the RT feature is enabled in the app asset created on Webex Connect and user registration is done, the App Developer can establish a connection between the app and Webex Connect platform by calling the connect method appropriately. This enables the messages sent from Webex Connect to be received on the app. When the application is running in the background, SDK is disconnected from Webex Connect. While in the disconnected state, incoming In-App messages are not received, however when the application comes to foreground again, SDK will establish a connection with the Webex Connect platform and allow messages to be received.
The connect method is used to establish a connection to receive Real-Time Messages from the Webex Connect platform. When the connection is successful, the status events are notified through ICMessagingDelegate didChangeConnectionStatus
.
It throws an error as defined if the user is not currently registered to the Webex Connect or if RTM feature is not enabled in the policy.
Syntax: - (BOOL)connect:(NSError **)error;
Example:
NSError * error;
[ICMessaging shared].delegate = self;
[[ICMessaging shared] connect: & error];
if (error) {
NSLog(@ "Connection Failed. Reason: %@", error.localizedDescription);
}
disconnect
This method is used to disconnect the connection between the app and the Webex Connect platform. If there is no active connection, then this method fails silently. When the disconnection is successful, the status events are notified through ICMessagingDelegate didChangeConnectionStatus
.
It throws an error as defined if the user is not currently registered with Webex Connect or if RTM feature is not enabled in the policy.
Syntax: - (BOOL)disconnect:(NSError **)error;
Example:
NSError * error;
[[ICMessaging shared] disconnect: & error];
if (error) {
NSLog(@ "Disconnection failed. Reason: %@", error.localizedDescription);
} else {
NSLog(@ "Disconnection succeeded.");
}
subscribeTopic
This method is used to subscribe to the passed topic, allowing the SDK to receive messages on that topic. If the subscription succeeds, error in completionHandler will be null. Incoming messages are received through ICMessagingDelegate didReceiveMessage
.
Syntax: - (void)subscribeTopic:(NSString *)topic completionHandler: (void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
topic | String | Specifies the topic name to subscribe. |
Example:
[[ICMessaging shared] subscribeTopic:topic completionHandler:^(NSError *error)
{
if (error)
{
NSLog(@"Subscription failed. Reason: %@", error.localizedDescription);
}
else
{
NSLog(@"Subscription succeeded.");
}
}];
unsubscribeTopic
This method is used to unsubscribe to the passed topic, preventing the SDK to receive messages on that topic. The messages may still be received until the callback has reported success (error == nil). The results of the operation are reported through the completionHandler
.
Syntax: - (void)unsubscribeTopic:(NSString *)topic completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
topic | String | Specifies the topic name to unsubscribe. |
Example:
[[ICMessaging shared] unsubscribeTopic:topic
completionHandler:^(NSError *error)
{
if (error)
{
NSLog(@"Unsubscription failed. Reason: %@", error.localizedDescription);
}
else
{
NSLog(@"Unsubscription succeeded.");
}
}];
publishMessage
This method is used to publish the passed ICMessage
instance through RTM connection. If the message is published, error in completionHandler
will be nil.
Syntax: - (void)publishMessage:(ICMessage *)message completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameters | Type | Description |
---|---|---|
message | ICMessage | Refer to ICMessage class. |
Example:
ICMessage *icMessage = [ICMessage new];
icMessage.message = @"My message";
icMessage.thread = thread;
[[ICMessaging shared] publishMessage:icMessage
completionHandler:^(NSError *error)
{
if (error)
{
NSLog(@"Publication failed. Reason: %@", error.localizedDescription);
}
else
{
NSLog(@"Publication succeeded.");
}
}];
setMessageAsReadForTransactionId
This method is used to update the status of the message identified by transactionId as Read. If the message status is set to read, error in completionHandler
will be nil.
Syntax: -(void)setMessageAsReadForTransactionId:(NSString *)transactionId completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
transactionId | String | Specifies a unique transaction id. |
[[ICMessaging shared] setMessageAsReadForTransactionId:message.transactionId
completionHandler:^(NSError *error)
{
if (error)
{
NSLog(@"Can't set the message: %@ to read. Reason: %@"
,message.transactionId
,error.localizedDescription);
}
else
{
NSLog(@"Message:%@ has been set as read", message.transactionId);
}
}];
setMessagesAsReadForTransactionIds
This method is used to update the status of the messages identified by transactionIds array as Read. The results of the operation are reported through the completionHandler
.
Syntax: -(void)setMessagesAsReadForTransactionIds:(NSArray *)transactionIds completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
transactionIds | NSArray | Specifies an array of unique transaction ids. |
setNotificationCategories
This method is used to register new notification categories that are used for interactive notifications.
Syntax: - (void)setNotificationCategories:(NSArray *)notificationCategories;
Parameters:
Parameter | Type | Description |
---|---|---|
notificationCategories | NSArray | Specifies an array of notificationCategories to register. |
handleActionWithIdentifier
This method is used to handles the interactive action or default action selected by a user. This method should be called only if the action is selected while the app is active. For the default action case, a nil identifier should be passed.
Syntax: - (void)handleActionWithIdentifier:(NSString *)identifier forMessage:(ICMessage *)message withResponse:(NSString *)response;
Parameters:
Parameter | Type | Description |
---|---|---|
identifier | NSString | Specifies an identifier of the action selected by the user (nil for default action). |
response | NSString | Specifies an extra response associated to the action. |
fetchTopics
This method is used to get a list of topics that are configured with the Webex Connect application. To control the type of topics that are returned, use the filter parameter.
Syntax: - (void)fetchTopics:(int)offset completionHandler:(void(^)(NSArray *topics, NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
offset | Integer | Pass offset value to fetch topics from that Offset value. |
completionHandler | NSError | Invoked when the response is received. |
Example:
[[ICMessaging shared] fetchTopics:0
completionHandler:^(NSArray *topics, NSError *error)
{
if (topics != nil && topics.count > 0)
{
for (ICTopic *topic in topics)
{
NSLog(@"Topic name: %@",topic.name);
}
}
}];
fetchStreams (Deprecated)
This method fetches a list of streams that have been configured to be used with the current Webex Connect application.
Syntax: - (void)fetchStreams:(void(^)(NSArray *streams, NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
completionHandler | NSError | Invoked when the response is received. |
Example:
[[ICMessaging shared] fetchStreams:^(NSArray *streams, NSError *error)
{
for (ICStream *stream in streams)
{
NSLog(@"Stream name: %@", stream.name);
}
}];
createThread
This method creates a thread based on a title for a stream.
Syntax: - (void)createThread:(ICThread *)thread completionHandler:(void(^)(ICThread *thread, NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | The thread that will be created |
completionHandler | (ICThread _thread, NSError _error) | A completionHandler with new thread and Error object. |
Example:
ICThread *newThread = [ICThread new];
newThread.category = @”Conversations”;
newThread.title = @”My New Thread”;
newThread.extras = @{@"firstName" : @"sample"}
[[ICMessaging shared] createThread:newThread
completionHandler:^(ICThread *thread, NSError *error)
{
NSLog(@"New thread created with Thread id: %@",thread.threadId);
}];
updateThread
This method is used to update the existing thread.
Syntax: - (void)updateThread:(ICThread *)thread completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | The thread to update |
completionHandler | (NSError *error) | A completion Handler with Error object to report operation is success or failure. |
Example:
ICThread *thread = <ICThread_To_Update>;
[[ICMessaging shared] updateThread:thread completionHandler:^(NSError *error) {
if (error == nil)
{
NSLog(@"Thread updated");
}
else
{
NSLog(@"Error while updating thread: %@",error.localizedDescription);
}
}];
closeThread
This method is used to close the existing thread.
Syntax: - (void)closeThread:(ICThread *)thread completionHandler:(void(^)(NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | The thread to close. |
completionHandler | (NSError *error) | A completion Handler with Error object to report operation is success or failure. |
Example:
ICThread *thread = <ICThread_To_Close>;
[[ICMessaging shared] closeThread:thread completionHandler:^(NSError *error) {
if (error == nil)
{
NSLog(@"Thread closed");
}
else
{
NSLog(@"Error while closing thread: %@",error.localizedDescription);
}
}];
fetchMessages
This method fetches a list of messages received or sent before the date parameter. The messages will be fetched 50 by 50. To see if more messages are available, check hasMoreMessages
parameter.
Syntax: - (void)fetchMessagesForThreadId:(NSString *) threadId untilDate:(NSDate *) date completionHandler:(void(^)(NSArray *messages, BOOL hasMoreMessages, NSError *error))completionHandler
Parameter | Type | Description |
---|---|---|
threadId | String | The threadId on which the messages have been received. |
date | Date | The date until when the messages will be fetched. |
Parameters:
Example:
[[ICMessaging shared] fetchMessagesForThreadId:@"My thread id"
untilDate:[NSDate date]
completionHandler:^(NSArray *messages, BOOL hasMoreMessages, NSError *error)
{
if (messages != nil && messages.count > 0)
{
for (ICMessage *message in messages)
{
NSLog(@"Message: %@",message.message);
}
}
}];
fetchThreads
This method is used to get a list of threads that are created before the date with limit passed and at least one message transaction completed. Results are reported through the ICFetchThreadsCallback callback.
Syntax:- (void)fetchThreadsUpdatedBeforeDate:(NSDate *)updatedBefore limit:(NSInteger)limit completionHandler:(void(^)(NSArray *threads, BOOL hasMoreThreads, NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
updatedBefore | NSDate | pass value to fetch Threads before that Date |
limit | NSInteger | pass value to limit the fetching thread count |
completionHandler | Integer | Invoked to report operation success or failure |
ICMessaging.getInstance().fetchThreads(beforeDate,10, new ICFetchThreadsCallback()
{
@Override
public void onFetchThreadsComplete(final ICThread[] threads, final boolean hasMoreData, final ICException exception)
{
if (exception != null)
{
Log.e("fetchThreads", "fetchThreads failed! Reason:" + exception.toString());
return;
}
Log.e("fetchThreads", "fetchThreads success:");
}
});
fetchThreadForCategory
This method fetches a list of threads which matches the given Category.
Syntax:- (void)fetchThreadsForCategory:(NSString *)category updatedBeforeDate:(NSDate *)updatedBefore limit:(NSInteger)limit completionHandler:(void(^)(NSArray *threads, BOOL hasMoreThreads, NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
category | NSString | The category on which the threads have been updated |
updatedBefore | NSDate | The date before which the threads have been updated |
limit | NSInteger | The max number of threads that will be received |
completionHandler | (NSArray _threads, BOOL hasMoreThreads, NSError _error) | A completionHandler called when the response is received. It will contain an array of threads or an error if the request failed. |
fetchThreadsForType
This method fetches a list of threads which matches the given Thread Type.
Syntax:- - (void)fetchThreadsForType:(ICThreadType)type updatedBeforeDate:(NSDate *)updatedBefore limit:(NSInteger)limit completionHandler:(void(^)(NSArray *threads, BOOL hasMoreThreads, NSError *error))completionHandler;
Parameters:
Parameter | Type | Description |
---|---|---|
type | ICThreadType | The type on which the threads have been updated. |
updatedBefore | NSDate | The date before which the threads have been updated |
limit | NSInteger | The max number of threads that will be received |
completionHandler | (NSArray _threads, BOOL hasMoreThreads, NSError _error) | A completionHandler called when the response is received. It will contain an array of threads or an error if the request failed. |
fetchMessages
This method is used to get a list of messages from connect platform. Results are reported through the ICFetchMessagesCallback callback.
Syntax: (void)fetchMessagesForThreadId:(NSString *)threadId untilDate:(NSDate *)date limit:(NSInteger)limit completionHandler:(void(^)(NSArray *messages, BOOL hasMoreMessages, NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | Specifies the ThreadId value. |
date | NSDate | Specifies the date before the messages needs to returned. |
limit | NSInteger | Pass value to limit the fetching message count |
completionHandler | Interger | Invoked to report operation success or failure |
ICMessaging.getInstance().fetchMessages(threadId,beforeDate,10, new ICFetchMessagesCallback()
{
@Override
public void onFetchMessagesComplete(final ICMessage[] messages, final boolean hasMoreData, final ICException exception)
{
if (exception != null)
{
Log.e("fetchMessages", "fetchMessages failed! Reason:" + exception.toString());
return;
}
Log.e("fetchMessages", "fetchMessages success:");
}
});
deleteMessage
This method is used to delete the given message transaction id from the Webex Connect platform.
Syntax: (void)deleteMessageForTransactionId:(NSString *)transactionId completionHandler:(void(^)(NSError *error))completionHandler
Parameters:
Parameter | Type | Description |
---|---|---|
messageTransactionId | String | The transaction id of the message. See ICMessage.getTransactionId() . |
NSString *messageTransactionId = message.getTransactionId();
[[ICMessaging shared] deleteMessageForTransactionId:messageTransactionId completionHandler:^(NSError *error)
{
if(error)
{
NSLog(@"DeleteMessage - Error: %@", error.localizedDescription);
return;
}
NSLog(@"DeleteMessage - PublMessage deleted successfully, transactionId: %@", messageTransactionId);
}];
deleteMessageForTransactionId
This method is used to delete the message for given TransactionId.
Syntax: - (void)deleteMessageForTransactionId:(NSString *)transactionId completionHandler:(void(^)(NSError *error))completionHandler;
Parameters
Parameter | Type | Description |
---|---|---|
transactionId | NSString | The transactionId of the message to delete. |
completionHandler | (NSError *error) | A completionHandler called when the response is received. If message is deleted, error in completionHandler will be nil. |
setFCMPushProvider
This method is used to set the ICFCMPushProvider.
Syntax: (void)setFCMPushProvider:(id<ICFCMPushProvider>)fcmPushProvider;
processFCMPushToken
This method is called to handle a new push token.
Syntax: (void)processFCMPushToken:(NSString *)token;
Make sure to create a class that will confirm to ICFCMPushProvider protocol and implements the FCM related methods as shown below.
FCMPushProvider.h
#import <Foundation/Foundation.h>
#import <IMIconnectCoreSDK/IMIconnectCoreSDK.h>
NS_ASSUME_NONNULL_BEGIN
@interface FCMPushProvider :NSObject <ICFCMPushProvider>
@end
NS_ASSUME_NONNULL_END
FCMPushProvider.m
#import "FCMPushProvider.h"
@import Firebase;
@interface FCMPushProvider()<FIRMessagingDelegate>
@property (nonatomic) NSString *fcmToken;
@end
@implementation FCMPushProvider
- (instancetype)init
{
if (self = [super init])
{
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
}
return self;
}
- (nonnull NSString *)getToken
{
return self.fcmToken;
}
- (void)subscribeToTopic:(nonnull NSString *)topic completionHandler:(nonnull void (^)(NSError * _Nullable))completionHandler
{
[[FIRMessaging messaging] subscribeToTopic:topic completion:completionHandler];
}
- (void)unsubscribeFromTopic:(nonnull NSString *)topic
{
[[FIRMessaging messaging] unsubscribeFromTopic:topic];
}
- (void)registerForFCM
{
@try
{
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
}
@catch (NSException *exception)
{
NSLog(@"Firebase exception: %@",exception.reason);
}
// Add observer for InstanceID token refresh callback.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFCMRefreshToken:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
}
// [START refresh_token]
-(void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken
{
NSLog(@"FCM registration token: %@", fcmToken);
self.fcmToken = fcmToken;
[self processFCMPushToken];
}
// [END refresh_token]
-(void)didFCMRefreshToken:(NSNotification *)notification
{
// Note that this callback will be fired everytime a new token is generated, including the first
// time. So if you need to retrieve the token as soon as it is available this is where that
// should be done.
[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result, NSError * _Nullable error) {
if (error == nil) {
NSString *refreshedToken = result.token;
self.fcmToken = refreshedToken;
[self processFCMPushToken];
}
}];
}
-(void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage
{
}
- (void)processFCMPushToken
{
if([IMIconnect isRegistered])
{
[[ICMessaging shared] processFCMPushToken:self.fcmToken];
}
}
@end
isConnectPushMessage
This method can be used to validate the passed message is Webex Connect's message or not. Returns YES if the message is from Webex Connect platform and returns NO if not.
Syntax: + (BOOL)isConnectPushMessage:(NSDictionary *)userInfo;
Parameters:
Parameter | Type | Description |
---|---|---|
userInfo | NSDictionary | The push message that needs to be validated |
*Example:
Bool isConnectMessage= [ICMessaging isConnectPushMessage: <push message dictionary>];
sendClickedEventForTransactionId
This method sends a click event to the messaging manager for the selected button and with the transaction ID.
Syntax: - (void)sendClickedEventForTransactionId:(NSString *)transactionId forButton:(ICButton *)button completionHandler:(void(^)(NSError *error))completionHandler;
Parameter | Type | Description |
---|---|---|
transactionId | NSString | The transactionId of the message |
button | ICButton | The interacted ICButton for which an ICMessage is created |
Return Value: NIL
Example:
[[ICMessaging shared] sendClickedEventForTransactionId:_message.transactionId forButton:_buttonObj completionHandler:^(NSError *error) {
NSLog(@"sendClickEvent ICInteractiveDataTypeWebURL error:%@",error);
}];
registerForRemoteNotifications
This method checks and registers the user for remote notifications.
Syntax: - (void)registerForRemoteNotifications;
Return Value: NIL
Sample Code:
[[ICMessaging shared] registerForRemoteNotifications];
ICMessagingActionsDelegate
This class allows you to override the process done after a user has clicked on an action displayed by an interactive notification.
shouldOverrideAction
This method is invoked whenever a user clicks on an action to know if the developer wants to override the internal process of the SDK. If not implemented, the default value is NO.
Syntax: - (BOOL)shouldOverrideAction:(NSString *)action withIdentifier:(NSString *)identifier forMessage:(ICMessage *)message;
Parameters:
Parameter | Type | Description |
---|---|---|
message | ICMessage | Refer to ICMessage class. |
identifier | NSString | Specifies an identifier of the action selected by the user. |
action | NSString | Specifies the action related to the notification. |
Example:
- (BOOL)shouldOverrideAction:(NSString *)action withIdentifier:(NSString *)identifier forMessage:(ICMessage *)message
{
return YES;
}
performAction
This method is invoked whenever a user clicks on an action and if shouldOverrideAction returns _YES _for this action.
Syntax: - (void)performAction:(NSString *)action withIdentifier:(NSString *)identifier forMessage:(ICMessage *)message withResponseInfo:(NSDictionary *)responseInfo;
Parameters:
Parameter | Type | Description |
---|---|---|
responseInfo | NSDictionary | Specifies an extra response associated to the action. |
message | ICMessage | Refer to ICMessage class. |
identifier | NSString | Specifies an identifier of the action selected by the user. |
action | NSString | Specifies the action related to the notification. |
Example:
- (void)performAction:(NSString *)action withIdentifier:(NSString *)identifier forMessage:(ICMessage *)message withResponseInfo:(NSDictionary *)responseInfo
{
NSLog(@"action: %@,message: %@",action,identifier,message.message);
}
ICMessagingDelegate
This class allows the interception of incoming messages and RTM connection status changes.
didReceiveMessage
This method is invoked whenever a new Push or RTM message is received. This method is invoked after internal processing is complete, such as local notification may have already been generated.
Syntax: - (void)didReceiveMessage:(ICMessage *)message fromTap:(BOOL)fromTap;
Parameters:
Parameter | Type | Description |
---|---|---|
message | ICMessage | The received message object |
fromTap | BOOL | Informs if the message has been received after a tap of the user or not |
Example:
- (void)didReceiveMessage:(ICMessage *)message fromTap:(BOOL)fromTap
{
NSLog(@"Received Message:%@, fromTap: %i", [message description], fromTap);
}
didChangeConnectionStatus
This method is invoked whenever there is a change in RTM connection status.
Syntax: (void) didChangeConnectionStatus:(ICConnectionStatus)connectionStatus;
Parameters:
Parameter | Type | Description |
---|---|---|
connectionStatus | ICConnectionStatus | Refer to ICConnectionStatus class. |
Example:
-(void) didChangeConnectionStatus: (ICConnectionStatus) connectionStatus {
switch (connectionStatus) {
case ICConnectionStatusConnected:
NSLog(@ "Connected");
break;
case ICConnectionStatusConnecting:
NSLog(@ "Connecting");
break;
case ICConnectionStatusNone:
case ICConnectionStatusError:
case ICConnectionStatusClosed:
case ICConnectionStatusRefused:
default:
NSLog(@ "Not Connected");
break;
}
}
ICDeviceTokenDelegate
A protocol that defines a delegate method for receiving updates to the APNS token.
Methods |
---|
didUpdateDeviceToken |
didUpdateDeviceToken
Notifies the delegate of an updated device token.
Syntax (void)didUpdateDeviceToken:(NSString *)deviceToken;
Parameters:
Parameter | Type | Description |
---|---|---|
deviceToken | NSString | The new device token as a string. |
ICInAppDisplay
A class responsible for configuring the display of in-app notifications.
Property | Description |
---|---|
@property (nonatomic, readonly) ICInAppNotificationType notificationType; | This property indicates whether the in-app notification should be displayed as a banner or a modal. |
@property (nonatomic, readonly) BOOL isExpandable; | A Boolean value indicating if the notification is expandable. |
ICMessage
This class exposes message data from the various channels (RTM and Push) in a generalized form and is also used to send Real-Time Messages from an app to the Webex Connect platform.
Property | Description |
---|---|
@property (nonatomic, readonly) NSString *category; | This property returns the category of message. The category will be used by the SDK to create an interactive notification. It will be nil if the message is basic. This property can be nullable. |
@property (nonatomic, readonly) ICMessageChannel channel; | This property returns the channel on which the message was received (Push or RTM). This property can not be null. |
@property (nonatomic) NSMutableDictionary *customTags; | This property refers to any custom, developer specified, data that was sent or to be sent as part of the message payload. This property can be nullable. |
@property (nonatomic, readonly) NSDictionary *extras; | This property returns any supplementary data that was sent as part of the message payload. This format of this data is controlled by the Webex Connect platform and enables certain standard features such as interactive messages. This property can be nullable. |
@property (nonatomic) NSString *message; | This property refers to the content of the message. Usually, this is the text that is displayed to the end-users. This property can be nullable. |
@property (nonatomic, readonly) int priority; | This property returns the priority of the message. |
@property (nonatomic, readonly) NSString *reference; | This property returns the message reference. |
@property (nonatomic) ICThread *thread; | This property refers to the thread object to which the message should belong |
@property (nonatomic, readonly) NSString *transactionId; | This property returns the transactionid which uniquely identifies the message transaction within the Webex Connect platform. This property can not be null. |
@property (nonatomic, readonly) ICMessageType type; | This property returns the type of the message. This property can not be null. |
@property (nonatomic, readonly) NSString *userId; | This property returns the _userId _from which the message originated. Returns _nil _if the message did not arrive from another user. This property can not be null. |
@property (nonatomic) ICMessageStatus status; | The message status such as None/Sent/NotSent/Delivered/Read. This property can not be null. |
@property (nonatomic, readonly) NSString *title; | The title of the message. |
@property (nonatomic) ICInAppDisplay *inAppDisplay; | The inAppDisplay related to the message |
@property (nonatomic, readonly) BOOL isOutgoing; | Informs if the message is an outgoing message |
@property (nonatomic, readonly) NSDate *submittedAt; | The date when the message has been submitted |
@property (nonatomic, readonly) NSDate *deliveredAt; | The date when the message has been delivered |
@property (nonatomic, readonly) NSDate *readAt; | The date when the message has been read |
@property (nonatomic, readonly) NSDate *createdAt; | The date when the message has been created |
@property (nonatomic) NSMutableArray *attachments; | Any attachments which are or have to be attached to the message |
@property (nonatomic) ICQuickReplyData *quickReplyData; | The quick reply data that have been attached to the message |
@property (nonatomic) ICQuickReplyData *quickReplyData; | The quick reply data that have been attached to the message |
Methods
Methods |
---|
initWithData |
initWithDictionary |
data |
dictionary |
initWithData
This method creates an instance of an ICMessage from data.
Syntax: (instancetype)initWithData:(NSData *)data;
Return value: Returns instance of ICMessage
initWithDictionary
This method creates an instance of an ICMessage based on a dictionary.
Syntax: (instancetype)initWithDictionary:(NSDictionary *)dictionary;
Return value: Returns instance of ICMessage
data
This method creates data from an ICMessage.
Syntax: (NSData *)data;
Return value: NSData
dictionary
This method creates a dictionary from an ICMessage.
Syntax: - (NSDictionary *)dictionary;
Return value: NSDictionary
ICTopic
This class exposes Push or Real-Time Messaging topic data that is used to publish outgoing messages or subscribe to receive incoming messages.
Property | Description |
---|---|
@property (nonatomic, readonly) NSString *name; | Returns the topic name. |
@property (nonatomic, readonly) BOOL isSubscribed; | Returns yes if a user is subscribed to the topic. |
@property (nonatomic, readonly) ICAccessLevel accessLevel; | Returns the topic access level (write or read-write). |
@property (nonatomic, readonly) NSString *createdBy; | Returns the name who created the topic. |
@property (nonatomic, readonly) NSDate *createdDate; | Returns the topic creation date. |
@property (nonatomic, readonly) NSDate *updatedDate; | Returns the date of the latest update on the topic. |
createdAt
This method is used to get the date on which the topic is created.
Syntax: @property (nonatomic, readonly) NSDate *createdAt
topicId
This method is used to get topic Id.
Syntax: @property (nonatomic, readonly) NSString *topicId
Return Value: Returns the ID for the topic.
name
This method is used to get the topic name.
Syntax: @property (nonatomic, readonly) NSString *name
getTitle
This method is used to get the topic title.
Syntax: public String getTitle()
Return Value: Returns the topic title.
group
This method is used to get the topic’s group.
Syntax: @property (nonatomic, readonly) NSString *group
isSubscribed
This method is used to verify whether the current user is subscribed to the topic.
Syntax: @property (nonatomic, readonly) BOOL isSubscribed
desc
This method is used to get the topic description.
Syntax: @property (nonatomic, readonly) NSString *desc
Return Type: Returns description of a topic.
ICThread
This class exposes the thread data from RTM and Push channels in a generalized form. It is also used to send Real-Time Messages from an application to the Webex Connect platform.
Property | Description |
---|---|
@property (nonatomic, readonly) NSString *threadId; | The thread id. |
@property (nonatomic) NSString *title; | The thread title. |
@property (nonatomic, readonly) NSDate *createdAt; | The thread creation date. |
@property (nonatomic, readonly) NSDate *updatedAt; | The update date of the thread. |
@property (nonatomic) ICThreadType type; | The thread type. |
@property (nonatomic, readonly) ICThreadStatus status; | The thread status. |
@property (nonatomic) NSString *category; | The thread category. |
@property (nonatomic) NSString *externalId; | The external id. |
@property (nonatomic) NSMutableDictionary *extras; | The thread extras. |
ICMessageData
transactionId
This method is used to retrieves the message’s transactionId.
Syntax: - (NSString *)transactionId
Return Value: Returns the transaction id.
status
This method is used to retrieves the message's status.
Syntax: - (ICMessageStatus)status
Return Value: Returns the status of the message.
date
This method is used to retrieves the date to be displayed in the inbox or in the conversation.
Syntax: - (NSDate *)date
Return Value: Returns the date that will be displayed.
isOutgoing
This method is used to informs if the message is outgoing or not.
Syntax: - (BOOL)isOutgoing
Return Value: Returns 'YES' if the message is outgoing, 'NO' otherwise.
thread
This method is used to retrieves the thread associated with the message
Syntax: (ICThread *)thread
Return Value: Returns the message’s thread.
type
This method is used to retrieves the message type.
Syntax: - (ICMessageType)type
Return Value: Returns the message’s type.
ICMessageSynchronizer
setPolicy
This method allows us to set the policy object which describes the extent of data to be synchronized.
Syntax: + (void)setPolicy:(ICMessageSynchronizationPolicy *)policy
parameter:
Parameter | Type | Description |
---|---|---|
policy | ICMessageSynchronizationPolicy | message synchronization policy object. |
ICMessageSynchronizationPolicy
Property | Description |
---|---|
@property (nonatomic) ICMessageSynchronizationMode mode | The mode of synchronization. |
@property (nonatomic) NSInteger maxThreads | The maximum number of threads that will be synchronized at once |
@property (nonatomic) NSInteger maxMessagesPerThread | The maximum number of messages that will be synchronized per thread |
init
This method instantiates a new policy
Syntax: (instancetype)initWithMode:(ICMessageSynchronizationMode)mode maxThreads:(NSInteger)maxThreads maxMessagesPerThread:(NSInteger)maxMessagesPerThread
parameter:
Parameter | Type | Description |
---|---|---|
mode | ICMessageSynchronizationMode | The synchronization mode |
maxThreads | NSInteger | maximum number of threads which will be synchronized. |
maxMessagesPerThread | NSInteger | maximum number of messages per thread which will be synchronized |
ICMessageStore
This protocol defines the methods used to persist and retrieve data from an underlying data storage mechanism. A default secure implementation will be provided by the SDK, but developers may also choose to provide their own implementation.
Methods |
---|
deleteAll deleteMessage deleteThread numberOfMessages numberOfThreads loadMessage loadMessages loadThread loadThreads saveMessage saveMessages saveThread saveThreads loadMessagesWithThreadId loadLatestOutgoingMessageWithThreadId loadUnreadThreadsWithLimit numberOfUnreadThreads |
deleteAll
This method deletes complete threads & messages
Syntax: - (BOOL)deleteAll
Return Value: Returns 'true' if deletion completes, 'false' Otherwise.
deleteMessage
This method deletes complete threads & messages
Syntax: - (BOOL)deleteMessageWithTransactionId:(NSString *)transactionId
Parameters:
Parameter | Type | Description |
---|---|---|
transactionId | NSString | The transactionId to be deleted from local storage |
Return Value: Returns true
if delete message completes, false
Otherwise.
deleteThread
This method allows us to delete single {@link ICThread} from local storage based on threadId.
Syntax: - (BOOL)deleteThreadWithThreadId:(NSString *)threadId
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | The threadId is deleted from local storage |
Return Value: Returns true
if delete thread completes, false
Otherwise.
numberOfMessages :
This method provides a count of messages from local storage based on threadId.
Syntax: - - (int)numberOfMessagesForThreadId:(NSString *)threadId
Parameters:
Parameter | Type | Description |
---|---|---|
Returns count of threads | NSString | The threadId to be fetched count from local storage |
Return Value: Returns count of messages.
numberOfThreads
This method provides the total number of threads count from local storage.
Syntax: - (int)numberOfThreads
Return Value: Returns count of threads.
loadMessage
This method loads single {@link ICMessage} from local storage based on transactionId.
Syntax: - (ICMessage *)loadMessageWithTransactionId:(NSString *)transactionId
Parameters:
Parameter | Type | Description |
---|---|---|
transactionId | NSString | The transactionId to be retrieved from local storage |
Return Value: {@link ICMessage} instance if message exists with transactionId.
loadMessages
This method Loads {@link ICMessage} from local storage based on threadId and submitted date with a specific limit
Syntax: - (NSArray *)loadMessagesWithThreadId:(NSString *)threadId submittedBefore:(NSDate *)submittedBefore submittedAfter:(NSDate *)submittedAfter limit:(int)limit
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | The threadId to be retrieved from local storage |
submittedBefore | NSDate | The submittedBefore to be used to fetch messages before submittedBefore from local storage |
submittedAfter | NSDate | The submittedAfter to be used to fetch messages after submittedAfter from local storage |
limit | int | The limit to be used to fetch limited number of messages from local storage |
Return Value: Array of {@link ICMessage} instance if message exists with threadId.
loadThread
This method loads single {@link ICThread} from local storage based on threadId
Syntax: - (ICThread *)loadThreadWithThreadId:(NSString *)threadId
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | The threadId to be retrieved from local storage |
Return Value: Returns {@link ICThread} instance if thread exists with threadId.
loadThreads
This method Loads {@link ICThread}s from local storage based date modifiedBefore with the specific limit
Syntax: - (NSArray *)loadThreadsUpdatedBeforeDate:(NSDate *)updatedBefore updatedAfter:(NSDate *)updatedAfter limit:(int)limit
Parameters:
Parameter | Type | Description |
---|---|---|
updatedBefore | NSDate | the updatedBefore to be used to fetch threads modified before from local storage |
updatedAfter | NSDate | the updatedAfter to be used to fetch threads modified after from local storage |
limit | int | the limit to be used to fetch limited number of threads from local storage |
Return Value: Returns array of {@link ICThread}s instance if threads exists between before & after modified date with limit.
loadThreads
This method Loads {@link ICThread}s from local storage based date modifiedBefore with a specific limit
Syntax: - (NSArray *)loadThreadsUpdatedBeforeDate:(NSDate *)updatedBefore limit:(int)limit
Parameters:
Parameters | Type | Description |
---|---|---|
updatedBefore | NSDate | The updatedBefore to be used to fetch threads modified before from local storage |
limit | int | The limit to be used to fetch limited number of threads from local storage |
Return Value: Returns array of {@link ICThread}s instance if threads exists before modified date with limit.
saveMessage
This method saves single {@link ICMessage}
Syntax: - (BOOL)saveMessage:(ICMessage *)message
Parameters:
Parameters | Type | Description |
---|---|---|
Message | ICMessage | The {@link ICMessage} to be saved |
Return Value: Return true
if message storage completes, false
Otherwise
saveMessages
This method saves multiple {@link ICMessage}s
Syntax: - (BOOL)saveMessages:(NSArray *)messages
Parameters:
Parameters | Type | Description |
---|---|---|
Messages | NSArray | The array of {@link ICMessage}s to be saved |
Return Value: Return true
if message storage completes, false
Otherwise.
saveThread
This method saves single {@link ICThread}
Syntax: - (BOOL)saveThread:(ICThread *)thread
Parameters:
Parameters | Type | Description |
---|---|---|
thread | ICThread | The {@link ICThread} to be saved |
Return Value: Return true
if thread storage completes, false
Otherwise.
saveThreads
This method saves multiple {@link ICMessage}s
Syntax: - BOOL)saveThreads:(NSArray *)threads
Parameters:
Parameters | Type | Description |
---|---|---|
threads | NSArray | The array of {@link ICThread}s to be saved |
Return Value: Return true
if thread storage completes, false
Otherwise.
loadMessagesWithThreadId
This method Loads ICMessage from local storage based on threadId and submitted date with a specific limit.
Syntax: - (NSArray *)loadMessagesWithThreadId:(NSString *)threadId submittedBefore:(NSDate *)submittedBefore limit:(int)limit;
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | The threadId to be retrieved from local storage |
submittedBefore | NSDate | The submittedBefore to be used to fetch messages before submittedBefore from local storage |
limit | int | The limit to be used to fetch limited number of messages from local storage |
Return value: Array of ICMessage instances if messages exists with threadId.
loadLatestOutgoingMessageWithThreadId
This method loads single outgoing ICMessage from local storage based on threadId.
Syntax: -- (ICMessage *)loadLatestOutgoingMessageWithThreadId:(NSString *)threadId;
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | NSString | The threadId to be retrieved from local storage |
Return Value: ICMessage instance if message exists with threadId
loadUnreadThreadsWithLimit
This method Loads some ICThread instance containing at least one unread message from local storage with specific limit.
Syntax: - (NSArray *)loadUnreadThreadsWithLimit:(int)limit;
Parameters:
Parameter | Type | Description |
---|---|---|
limit | int | The limit to be used to fetch limited number of threads from local storage |
Return Value: An array of ICThread instances with some unread messages.
numberOfUnreadThreads
This method gives the total number of threads containing unread messages.
Syntax: - (NSInteger)numberOfUnreadThreads;
Return Value: The number of threads containing unread messages
ICDefaultMessageStore
This class provides a default secure ICMessageStore
implementation which enables out of the box data persistence support.
Syntax: - (instancetype)initWithPassword:(NSString *)password
Parameters:
Parameter | Type | Description |
---|---|---|
password | NSString | Specifies a password to secure the database. |
ICInteractiveData
This class exposes the data related to the form response submitted by users.
Properties:
Property | Description |
---|---|
@property (nonatomic, readonly) ICInteractiveDataType type; | The Type of the InteractiveData |
@property (nonatomic, readonly) NSDate *submittedAt; | The date when the Data has been submitted |
@property (nonatomic) NSMutableDictionary *payLoad; | The Interactivedata Payload |
@property (nonatomic, readonly) NSString *relatedTransactionId; | The transaction id for message Data response |
@property (nonatomic) NSString *identifier; | The identifier of the Interactive Data |
@property (nonatomic) NSString *actionURL; | The actionurl that can be used to render the image of the Interactive Button |
@property (nonatomic) NSString *title; | The title of the Interactive Button |
@property (nonatomic) NSString *reference; | The theme/subject of the Interactive Button |
@property (nonatomic, readonly) NSString *relatedTransactionId; | The transaction id for message Data response |
@property (nonatomic) NSString *identifier; | The identifier of the Interactive Data |
@property (nonatomic) NSString *actionURL; | The actionurl that can be used to render the image of the Interactive Button |
@property (nonatomic) NSString *title; | The title of the Interactive Button |
ICFormField
This class exposes the data related to a Form Field of a Form template.
Properties:
Property | Description |
---|---|
@property (nonatomic, readonly) ICFormFieldType formFieldType; | The Form Field id |
@property (nonatomic, readonly) NSString *fieldName; | The Form Field Name |
@property (nonatomic, readwrite) NSString *fieldValue; | The Form Field Value |
@property (nonatomic, readonly) NSString *fieldLabel; | The Form Field Label |
@property (nonatomic, readonly) NSString *fieldDescription; | The Form Field Description |
@property (nonatomic, readonly) BOOL isMandatory; | The Form Field is Mandatory |
@property (nonatomic, readonly) NSArray *dropdownOptions; | The Form Field Dropdown Options |
@property (nonatomic, readwrite) NSArray *fieldValues | The Form Field multi select drop down values |
Methods
typeFromString:typeString
This method Converts the Field Type String to ICFormFieldType.
Syntax: + (ICFormFieldType)typeFromString:(NSString *)typeString;
Parameters:
Parameter | Type | Description |
---|---|---|
typeString | NSString | Specifies the form field type |
Return Value: Returns the ICFormFieldType value equals to typeString passed to this method.
Sample Code:
ICFormFieldType formFieldType = [ICFormField typeFromString:@”email”];
stringFromType:type:
This method Converts the ICFormFieldType to String.
Syntax: + (NSString *)stringFromType:(ICFormFieldType)type;
Parameters:
Parameter | Type | Description |
---|---|---|
type | ICFormFieldType | Specifies the form field type |
Return Value: Returns the string value equals to ICFormFieldType passed to this method.
Sample Code:
NSString *formFieldType = [ICFormField stringFromType: ICFormFieldTypeEmail];
ICFCMPushProvider
This is protocol class to handle the FCM related methods.
getToken
Gets the FCM push registration token.
Syntax: - (NSString *)getToken;
subscribeToTopic
To subscribe to a topic, call the subscription method
Syntax: - (void) subscribeToTopic:(NSString )topic completionHandler:(void (^)(NSError _Nullable error))completionHandler;
unsubscribeFromTopic
To unsubscribe to a topic
Syntax: - (void) unsubscribeFromTopic:(NSString *)topic;
ICMessaging
Sets the ICFCMPushProvider
setFCMPushProvider
Syntax: - (void)setFCMPushProvider:(id)fcmPushProvider;
processFCMPushToken
Called to handle new push token.
Syntax: - (void)processFCMPushToken:(NSString *)token;
Sample Code:
User should create a class which handles the FireBase setup like registration, FCM Push Token, subscribing to topics etc. Then user has to set that class’s instance as FCM Push Provider as shown below.
FCMPushProvider *fcmPushProvider = [FCMPushProvider new];
[[ICMessaging shared] setFCMPushProvider:fcmPushProvider]
ICButton
This class exposes the data related to interactive button in quick replies and generic templates.
Properties:
Property | Description |
---|---|
@property (nonatomic, readonly) ICInteractiveDataType type; | The Type of the Interactive Data |
@property (nonatomic, readonly) NSString *identifier; | The ID of the Button |
@property (nonatomic) NSString *actionURL; | The url that can be used to open web_link and deeplink |
@property (nonatomic) NSString *imageURL; | The image url that can be used to render the image of the Button |
@property (nonatomic) NSString *title; | The title of the Button |
@property (nonatomic) NSMutableDictionary *payLoad; | The Payload of the Button |
Methods:
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
This method Creates an instance of an ICButton based on a dictionary
Syntax: - (instancetype)initWithDictionary:(NSDictionary *)dictionary;
Properties:
Parameter | Type | Description |
---|---|---|
dictionary | NSDictionary | The dictionary from which an ICButton is created |
Return Value: Returns the ICButton instance which is been created with the dictionary passed
Sample Code:
ICButton *quickReply = [[ICButton alloc] initWithDictionary:[ NSDictionary new]];
ICGenericTemplateElement
This class exposes the data related to generic template element.
Properties:
Property | Description |
---|---|
@property (nonatomic, readonly) NSString * title; | The title of the generic template element |
@property (nonatomic) NSString * subTitle; | The subTitle of the generic template element |
@property (nonatomic) NSArray _imageURLs; | The array of image urls |
@property (nonatomic) NSArray _buttons; | The array of template buttons |
ICQuickReplyData
This class exposes the data related to quick reply data.
Properties:
Property | Description |
---|---|
@property (nonatomic) NSMutableArray _buttons; | The quick replies that have been attached to the message |
@property (nonatomic) NSString *reference; | The reference of the QuickReply Data |
Updated 28 days ago