Core
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:
Parameter | Type | Description |
---|---|---|
error | NSError | Specifies 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:
Parameter | Type | Description |
---|---|---|
config | ICConfig | Refer to ICConfig class. |
error | NSError | Specifies 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:
Parameter | Type | Description |
---|---|---|
interval | NSTimeInterval | Specifies 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 Method | Description |
---|---|---|
+(NSString *)deviceId | +(ICDeviceProfile *)deviceProfile | Retrieves 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:
Parameter | Type | Description |
---|---|---|
token | String | Specifies 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.
Property | Description |
---|---|
@property (nonatomic) NSString *deviceId | Device ID. |
@property (nonatomic) NSString *appUserId | App user ID. |
@property (nonatomic) BOOL isAppUserIdSystemGenerated | Indicates if the app user ID has been generated by the system. |
@property (nonatomic) NSString *customerId | Customer ID. |
Methods | Description |
---|---|
(instancetype)initWithDeviceId:(NSString *)deviceId | Instantiates an ICDeviceProfile with a deviceId . |
(instancetype)initWithDeviceId:(NSString ) deviceId appUserId:(NSString )appUserId | Instantiates an ICDeviceProfile with a deviceId and an appUserId . |
(NSString *)defaultDeviceId | Retrieves 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.
Property | Description |
---|---|
@property (nonatomic, readonly) NSString *appId | Specifies the app id of the app created in IMIconnect. |
@property (nonatomic, readonly) NSString *clientKey | Specifies the client key of the app created in IMIconnect. |
@property (nonatomic, readonly) NSString *groupIdentifier | The app group identifier. This group identifier is used to retrieve information between the CoreSDK and the NotificationServiceExtension. |
@property (nonatomic, readonly) NSString *serverDomain | Specifies 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:
Parameter | Type | Description |
---|---|---|
appId | NSString | Specifies the app id that is created in IMIconnect |
clientKey | NSString | Specifies 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:
Parameter | Type | Description |
---|---|---|
appId | NSString | Specifies the app id that is created in IMIconnect |
clientKey | NSString | Specifies the client key that is created in IMIconnect |
groupIdentifier | NSString | Specifies 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:
Parameter | Type | Description |
---|---|---|
appId | NSString | Specifies the app id that is created in IMIconnect |
clientKey | NSString | Specifies the client key that is created in IMIconnect |
serverDomain | NSString | Specifies 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:
Parameter | Type | Description |
---|---|---|
appId | NSString | Specifies the app id that is created in IMIconnect |
clientKey | NSString | Specifies the client key that is created in IMIconnect |
groupIdentifier | NSString | Specifies the app group identifier associated to the app |
serverDomain | NSString | Specifies 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:
Parameter | Type | Description |
---|---|---|
logType | ICLogType | The type of logs that will be logged. |
target | ICLogTarget | The 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:
Parameter | Type | Description |
---|---|---|
days | Integer | The 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:
Parameters | Type | Description |
---|---|---|
eventParams | NSDictionary | The eventParams for custom params which needs to be published |
completionHandler | void (^)(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");
}];
Updated almost 2 years ago