This interface has two classes that handles the SDK initialization and registration. The classes are:

IMIconnect

This class contains the methods to initialize the SDK and register a user. When integrating the SDK into your app, it is mandatory to use this class to initialize the SDK. With exception to the Authentication module, it is also necessary to register a user before other features are used.

startup


This method is used to initialize the SDK. It reads the configuration from the file IMIconnectConfiguration.plist. You can pass an error in parameter, which will be set if any error occurs during the startup process. You need not use this method if you are using the [ICAppDelegate didFinishLaunchingWithOptions:] method.

  Syntax: + (BOOL)startup:(NSError **)error;

  Parameters:

ParameterTypeDescription
errorNSErrorSpecifies the error description.

startupWithConfig


This method is used to initialize the SDK using the provided configuration options. You can pass an error in parameter, which will be set if something wrong occurs during the startup process.

  Syntax: + (BOOL)startupWithConfig:(ICConfig *)config error:(NSError **)error;

  Parameters:

ParameterTypeDescription
configICConfigRefer to ICConfig class.
errorNSErrorSpecifies the error description.

  Example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ICConfig *config = [[ICConfig alloc] initWithClientKey:@"<Your client key>" forAppId:@"<Your App Id>"];
    NSError *error;
    [IMIconnect startupWithConfig:config error:&error];
    if (error != nil)
    {
        NSLog(@"Start up failed. Error: %@",error.localizedDescription);
    }
  	[super application:application didFinishLaunchingWithOptions:options]
    return YES;
}

shutdown


This method is used to cleanup the SDK, freeing all internal object instances. Invoking this method will stop the SDK features from functioning as such Real Time Messages and Push notifications.

📘

Usage of this method is not required unless there are a few limited cases where you may wish to use it; for example, if you are only using the Authentication or Monitoring features.

registerWithDeviceProfile


This method registers the device profile with the SDK. This method causes profile details to be sent to the IMIconnect platform. Once a profile is registered, all further SDK calls take place in the context of that profile.

  Syntax: (void)registerWithDeviceProfile:(ICDeviceProfile *)deviceProfile completionHandler:(void (^)(NSDictionary *response,NSError *error))completionHandler

ICDeviceProfile *deviceProfile = [[ICDeviceProfile alloc]
initWithDeviceId: [ICDeviceProfile defaultDeviceID]];
[IMIconnect registerWithDeviceProfile:deviceProfile
completionHandler:^(NSDictionary*response, NSError *error)
{
		//Handle the response
}];

deviceProfile


This method retrieves the current registered device profile.

  Syntax: + (ICDeviceProfile *)deviceProfile

isRegistered


This method is used to check whether the user is currently registered with IMIconnect. This method returns true if the user is registered, else false is returned.

  Syntax: + (BOOL)isRegistered;

setPolicyPollingInterval


This method is used to set the interval at which the SDK will poll policy updates in minutes. To prevent adverse affects on battery or CPU usage a minimum interval of 30 minutes is enforced. To disable polling, set the value to 0. If Real Time Messaging or Push is enabled, this value will not be used.

  Syntax: +(void)setPolicyPollingInterval:(NSTimeInterval)interval;

  Parameters:

ParameterTypeDescription
intervalNSTimeIntervalSpecifies the time in minutes after which policy updates will happen.

policyPollingInterval


This method is used to get the current policy polling interval, in minutes.

  Syntax: +(NSTimeInterval)policyPollingInterval;

updateDeviceProfileParam


This method updates the device profile parameter identified by ICDeviceProfileParam with a new value.

  Syntax: + (void)updateDeviceProfileParam:(ICDeviceProfileParam)deviceProfileParam withValue:(NSString *)value completionHandler:(void (^)(NSDictionary *response,NSError *error))completionHandler

[IMIconnect updateDeviceProfileParam:ICDeviceProfileParamCustomerId 

                                           withValue:_userIdTextField.text 

                                   completionHandler:^(NSDictionary *response, NSError *error) 

                 { 

                     //Handle response 

                 }];

deviceProfile


This method retrieves the deviceId used by IMIconnect APIs.

  Syntax: + (ICDeviceProfile *)deviceProfile

Method (Deprecated)New MethodDescription
  +(NSString *)deviceId  +(ICDeviceProfile *)deviceProfileRetrieves the deviceId used by IMIconnect APIs.

removeDeviceProfileParam


This method removes the device profile parameter identified by ICDeviceProfileParam with a new value.

  Syntax: + (void)removeDeviceProfileParam:(ICDeviceProfileParam)completionHandler:(void (^)(NSDictionary *response,NSError *error))completionHandler

[IMIconnect removeDeviceProfileParam:ICDeviceProfileParamUserId
									completionHandler:^(NSDictionary *response, NSError *error)
{
	//Handle the response
}];

unregister


This method unregisters the current device profile.

  Syntax: + (void)unregister:(void (^)(NSError *error))completionHandler

sdkVersion


This method retrieves the SDK version number.

  Syntax: + (NSString *)sdkVersion;

  Return Value: Returns the SDK version number.

setSecurityToken


This method is used to set security token to provide better access control for user-centric resources. This method allows developers to specify the Security Token that the SDK will pass to the Gateway API calls.

  Syntax: + (void)setSecurityToken:(NSString *)token;

  Parameters:

ParameterTypeDescription
tokenStringSpecifies the token which is generated from jwttoken API.

  Example:

TokenRequest *tokenRequest = [TokenRequest new]; 
        [tokenRequest requestTokenWithUserId:userId 
                                       appId:appId 
                                   expiresIn:self.expirationTime 
                           completionHandler:^(NSString *token, NSError *error) 
         { 
             if (token != nil) 
             { 
                 [IMIconnect setSecurityToken:token]; 
             } 
             if (completionHandler != nil) 
             { 
                 completionHandler(token,error); 
             } 
         }];

setSecurityTokenErrorDelegate


This method allows developers to register an object which implements the SecurityTokenExceptionListener interface to listen for Security Token related exceptions which occur from internal (indirect) Gateway API calls.

  Syntax:
+ (void)setSecurityTokenErrorDelegate(id<ICSecurityTokenErrorDelegate>)delegate;

  Example:

[IMIconnect setSecurityTokenErrorDelegate:self];

ICDeviceProfile

ICDeviceProfile is a class that gathers information about the back-end device profile. An ICDeviceProfile instance should be instantiated to register a device profile.
The developer can choose to register the device profile with a deviceId only or with a deviceId and an appUserId. User can generate a unique/own device ID or can choose the defaultDeviceId provided by the SDK.
If the user chooses to register a device profile with the deviceId only, the backend will automatically generate an appUserId. The current device profile is accessible via the IMIconnect class.

MethodsDescription
(instancetype)initWithDeviceId:(NSString *)deviceIdInstantiates an ICDeviceProfile with a deviceId.
(instancetype)initWithDeviceId:(NSString )

deviceId appUserId:(NSString
)appUserId
Instantiates an ICDeviceProfile with a deviceId and an appUserId.
(NSString *)defaultDeviceIdRetrieves the default device ID based on the vendor ID of the device.

ICConfig

This class holds the configuration information that is used to initialize the SDK.

PropertyDescription
@property (nonatomic, readonly) NSString *appIdSpecifies the app id of the app created in IMIconnect.
@property (nonatomic, readonly) NSString *clientKeySpecifies the client key of the app created in IMIconnect.
@property (nonatomic, readonly) NSString *groupIdentifierThe app group identifier. This group identifier is used to retrieve information between the CoreSDK and the NotificationServiceExtension.
@property (nonatomic, readonly) NSString *serverDomainSpecifies server domain configuration to override zero-rating domain.

initWithAppId:withAppId:clientkey

This method is used to initialize an ICConfig instance with an appId and clientkey.

Syntax: - (instancetype)initWithAppId:(NSString *)appId clientKey:(NSString *)clientKey;

Parameters:

ParameterTypeDescription
appIdNSStringSpecifies the app id that is created in IMIconnect
clientKeyNSStringSpecifies the client key that is created in IMIconnect

Returns:

An instance of ICConfig.

initWithAppId:withAppId:clientkey:groupIdentifier

This method is used to initialize an ICConfig instance with an appId, clientkey and groupIdentifier.

Syntax - initWithAppId:(NSString *)appId clientKey:(NSString *)clientKey groupIdentifier:(NSString *)groupIdentifier;

Parameters:

ParameterTypeDescription
appIdNSStringSpecifies the app id that is created in IMIconnect
clientKeyNSStringSpecifies the client key that is created in IMIconnect
groupIdentifierNSStringSpecifies the app group identifier associated to the app

Returns:

An instance of ICConfig.

initWithAppId:withAppId:clientkey:serverDomain

This method is used to initialize an ICConfig instance with an appId, clientkey, and serverDomain.

Syntax - (instancetype)initWithAppId:(NSString *)appId clientKey:(NSString *)clientKey serverDomain:(NSString *)serverDomain;

Parameters:

ParameterTypeDescription
appIdNSStringSpecifies the app id that is created in IMIconnect
clientKeyNSStringSpecifies the client key that is created in IMIconnect
serverDomainNSStringSpecifies server domain to override zero-rating domain

Returns:

An instance of ICConfig.

initWithAppId:withAppId:clientkey:groupIdentifier:serverDomain

This method is used to initialize an ICConfig instance with an appId, clientkey, groupIdentifier, and serverDomain.

Syntax - initWithAppId:(NSString *)appId clientKey:(NSString *)clientKey groupIdentifier:(NSString *)groupIdentifier serverDomain:(NSString *)serverDomain;

Parameters:

ParameterTypeDescription
appIdNSStringSpecifies the app id that is created in IMIconnect
clientKeyNSStringSpecifies the client key that is created in IMIconnect
groupIdentifierNSStringSpecifies the app group identifier associated to the app
serverDomainNSStringSpecifies server domain to override zero-rating domain

Returns:

An instance of ICConfig.

ICLogger

setLogType


This method sets the log options for the logger.

  Syntax: + (void)setLogType:(ICLogType)logType forLogTarget:(ICLogTarget)logTarget

  Parameters:

ParameterTypeDescription
logTypeICLogTypeThe type of logs that will be logged.
targetICLogTargetThe target on which the logs will be displayed/recorded.

setRetentionDuration


This method sets the retention duration of the logs. The logs will be kept during that duration and will be automatically purged after.

  Syntax: + (void)setRetentionDuration:(NSInteger)days

  Parameters:

ParameterTypeDescription
daysIntegerThe number of days after which the logs will be purged.

logPath


This method retrieves the directory path where the logs are stored.

  Syntax: + (NSString *)logPath

  Return Value: Returns the directory path where the logs are stored.

publishEvent


Invoke publishEvent to publish your custom events info to the IMIconnect platform.

  Syntax: + (void)publishEventParam:(NSDictionary *)eventParams completionHandler:(void (^)(NSDictionary *response, NSError *error))completionHandler

  Parameters:

ParametersTypeDescription
eventParamsNSDictionaryThe eventParams for custom params which needs to be published
completionHandlervoid (^)(NSDictionary response, NSError error)A completionHandler that will be called when a response from the server is received

  Example:

NSDictionary *eventParams = [NSDictionary new];
    [eventParams setValue:@"9123443212" forKey:@"number"];
    [eventParams setValue:@"234642" forKey:@"OTP"];
    
    [IMIconnect publishEventParam:eventParams completionHandler:^(NSDictionary *response, NSError *error)
    {
        if(error != nil)
        {
            NSLog(@"Publish failed, error: %@", error.localizedDescription);
            return;
        }
        
        NSLog(@"Published successfully");
    }];