Messaging

This interface enables publication and receipt of Real-Time Messages and Push Notifications.

This interface has the following classes:

ICAppDelegate

This class is mandatory to use push notifications.

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 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 RTM.

  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 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 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 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 IMIconnect. A delivery report will be send 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 IMIconnect.

  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.

PropertyDescription
@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 RTM connection is currently connected.
@property (nonatomic, readonly) ICConnectionStatus connectionStatus;This property returns the current connection status between the SDK and the IMIconnect platform.
@property (nonatomic) id messageStoreThe ICMessageStore implementation which the SDK will use to store data. Passing a null value is valid and disables storage capability.

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 IMIconnect and user registration is done, the App Developer can establish a connection between the app and IMIconnect platform by calling the connect method appropriately. This enables the messages sent from IMIconnect to be received on the app. When the application is running in the background, SDK is disconnected from IMIconnect. 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 IMIconnect platform and allow messages to be received.

The connect method is used to establish a connection to receive Real Time Messages from IMIconnect 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 IMIconnect 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 IMIconnect 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 IMIconnect 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:

ParameterTypeDescription
topicStringSpecifies 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:

ParameterTypeDescription
topicStringSpecifies 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:

ParametersTypeDescription
messageICMessage 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:

ParameterTypeDescription
transactionIdStringSpecifies 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:

ParameterTypeDescription
transactionIdsNSArraySpecifies 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:

ParameterTypeDescription
notificationCategoriesNSArraySpecifies 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:

ParameterTypeDescription
identifierNSStringSpecifies an identifier of the action selected by the user (nil for default action).
responseNSStringSpecifies an extra response associated to the action.

fetchTopics


This method is used to get a list of topics that are configured with IMIconnect 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:

ParameterTypeDescription
offsetIntegerPass offset value to fetch topics from that Offset value.
completionHandlerNSErrorInvoked 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 which have been configured to be used with the current IMIconnect application.

  Syntax: - (void)fetchStreams:(void(^)(NSArray *streams, NSError *error))completionHandler

  Parameters:

ParameterTypeDescription
completionHandlerNSErrorInvoked 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) createThreadWithTitle:(NSString *) title forStreamName:(NSString *) streamName completionHandler:(void(^) (ICThread *thread, NSError *error)) completionHandler

  Parameters:

ParameterTypeDescription
titleStringThe title of the thread that will be created.
streamNameStringThe stream name linked to the thread.
completionHandlerErrorA completionHandler that will be called once the response is receive.

  Example:

[[ICMessaging shared] createThreadWithTitle:@"My new thread title"
                                  forStreamName:@"My Stream name"
                              completionHandler:^(ICThread *thread, NSError *error)
     {
         if (thread != nil)
         {
             NSLog(@"Thread id: %@",thread.threadId);
         }
     }];

  Example:

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

ParameterTypeDescription
threadIdStringThe threadId on which the messages have been received.
dateDateThe 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:

ParameterTypeDescription
updatedBeforeNSDatepass value to fetch Threads before that Date
limitNSIntegerpass value to limit the fetching thread count
completionHandlerIntegerInvoked 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:");
   }
});

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:

ParameterTypeDescription
threadIdNSStringSpecifies the ThreadId value.
dateNSDateSpecifies the date before the messages needs to returned.
limitNSIntegerPass value to limit the fetching message count
completionHandlerIntergerInvoked 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:");

   }
});

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:

ParameterTypeDescription
messageICMessageRefer to ICMessage class.
identifierNSStringSpecifies an identifier of the action selected by the user.
actionNSStringSpecifies 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:

ParameterTypeDescription
responseInfoNSDictionarySpecifies an extra response associated to the action.
messageICMessageRefer to ICMessage class.
identifierNSStringSpecifies an identifier of the action selected by the user.
actionNSStringSpecifies 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);

  Parameters:

ParameterTypeDescription
messageICMessageRefer to ICMessage class.

  Example:

- (void)didReceiveMessage:(ICMessage *)message
{
NSLog(@"%@", [message description]);
}

didChangeConnectionStatus


This method is invoked whenever there is a change in RTM connection status.

  Syntax: (void) didChangeConnectionStatus:(ICConnectionStatus)connectionStatus;

  Parameters:

ParameterTypeDescription
connectionStatusICConnectionStatusRefer 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;
    }
}

ICMediaFile

This class exposes data relating to media file attachments that are received through RTM or Push, also used to attach media files to outgoing RTM messages.

PropertyDescription
@property (nonatomic) NSString *contentType;This property refers to the content type of the media such as image or video.
@property (nonatomic) long duration;This property refers to the duration of the media in seconds. It is applicable to audio and video files.
@property (nonatomic) double latitude;This property refers to the latitude associated with the media.
@property (nonatomic) double longitude;This property refers to the longitude associated with the media.
@property (nonatomic) UIImage *preview;This property refers to the preview thumbnail as a UIImage.
@property (nonatomic) long size;This property refers to the size of the file in bytes.
@property (nonatomic) NSURL *url;This property refers to a URL to where the file is located.

ICMessage

This class exposes message data from the various channels (RTM and Push) in a generalised form and is also used to send Real Time Messages from an app to the IMIconnect platform.

PropertyDescription
@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 IMIconnect platform and enables certain standard features such as interactive messages. This property can be nullable.
@property (nonatomic) NSMutableArray *medias;This property refers to any media file which are or has to be attached to the message. 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, readonly) NSString *replyToTopic;This property returns the topic to which replies should be sent.
@property (nonatomic) NSString *conversationId;This property refers to the conversationId, this is an arbitrary value to identify the conversation on which the message belongs.
@property (nonatomic) NSString *topic;This property refers to the topic on which the message was received or sent.
@property (nonatomic, readonly) NSString *transactionId;This property returns the transactionid which uniquely identifies the message transaction within the IMIconnect 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.

ICTopic

This class exposes Push or Real Time Messaging topic data that is used to publish outgoing messages or subscribe to receive incoming messages.

PropertyDescription
@property (nonatomic, readonly) NSString *name;Returns the topic name.
@property (nonatomic, readonly) BOOL isSubscribed;Returns yes if a user is subscribed the topic.
@property (nonatomic, readonly) ICAccessLevel accessLevel;Returns the topic access level (write or readwrite).
@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 in the topic.

createdAt


This method is used to get 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 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 IMIconnect platform.

PropertyDescription
@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.java

setPolicy


This method allows to set the policy object which describes the extent of data to be synchronized.

  Syntax: + (void)setPolicy:(ICMessageSynchronizationPolicy *)policy

  parameter:

ParameterTypeDescription
policyICMessageSynchronizationPolicymessage synchronization policy object.

ICMessageSynchronizationPolicy.java

PropertyDescription
@property (nonatomic) ICMessageSynchronizationMode modeThe mode of synchronization.
@property (nonatomic) NSInteger maxThreadsThe maximum number of threads that will be synchronized at once
@property (nonatomic) NSInteger maxMessagesPerThreadThe 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:

ParameterTypeDescription
modeICMessageSynchronizationModeThe synchronization mode
maxThreadsNSIntegermaximum number of threads which will be synchronized.
maxMessagesPerThreadNSIntegermaximum 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

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:

ParameterTypeDescription
transactionIdNSStringThe transactionId to be deleted from local storage

  Return Value: Returns true if delete message completes, false Otherwise.

deleteThread


This method allows to delete single {@link ICThread} from local storage based on threadId.

  Syntax: - (BOOL)deleteThreadWithThreadId:(NSString *)threadId

  Parameters:

ParameterTypeDescription
threadIdNSStringThe 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:

ParameterTypeDescription
Returns count of threadsNSStringThe threadId to be fetched count from local storage

  Return Value: Returns count of messages.

numberOfThreads


This method provides 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:

ParameterTypeDescription
transactionIdNSStringThe 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:

ParameterTypeDescription
threadIdNSStringThe threadId to be retrieved from local storage
submittedBeforeNSDateThe submittedBefore to be used to fetch messages before submittedBefore from local storage
submittedAfterNSDateThe submittedAfter to be used to fetch messages after submittedAfter from local storage
limitintThe 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:

ParameterTypeDescription
threadIdNSStringThe 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:

ParameterTypeDescription
updatedBeforeNSDatethe updatedBefore to be used to fetch threads modified before from local storage
updatedAfterNSDatethe updatedAfter to be used to fetch threads modified after from local storage
limitintthe 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 specific limit

  Syntax: - (NSArray *)loadThreadsUpdatedBeforeDate:(NSDate *)updatedBefore limit:(int)limit

  Parameters:

ParametersTypeDescription
updatedBeforeNSDateThe updatedBefore to be used to fetch threads modified before from local storage
limitintThe 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:

ParametersTypeDescription
MessageICMessageThe {@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:

ParametersTypeDescription
MessagesNSArrayThe 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:

ParametersTypeDescription
threadICThreadThe {@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:

ParametersTypeDescription
threadsNSArrayThe array of {@link ICThread}s to be saved

  Return Value: Return true if thread storage completes, false Otherwise.

ICDefaultMessageStore

This class provides a default secure ICMessageStore implementation which enables out of the box data persistence support.

  Syntax: - (instancetype)initWithPassword:(NSString *)password

  Parameters:

ParameterTypeDescription
passwordNSStringSpecifies a password to secure the database.