startup

Initializes the SDK by reading configuration data from the application. You can configure imiconnect through config.xml.

```xml 
<!-- IMIconnect app credentials -->  
<preference name="imiconnect_app_id" value="<APP_ID>" />  
<preference name="imiconnect_client_key" value="<CLIENT_KEY>" />  
<!-- OPTIONAL Add the IMIconnect's server environment, by default is UK -->  
<preference name="imiconnect_environment" value="<SERVER_ENVIRONMENT>" />  
<!-- OPTIONAL Add the server domain to override zero-rating domain -->  
<preference name="imiconnect_server_domain" value="<SERVER_DOMAIN>" />      
<!-- OPTIONAL (iOS Only) Application Group Identifier --> 
<preference name="imiconnect_group_identifier" value="<IOS_GROUP_IDENTIFIER>" /> 
<!-- OPTIONAL allows creating a default SQLite database when SQLcipher fails. --> 
<preference name="imiconnect_allow_unencrypted_database_fallback" value="<true/false>" /> 
```
IMIconnectPlugin.startup(function(result) { 
    //result will be Boolean value. 
    console.log("IMIconnectPlugin.startup(): " + result); 
}, function(error) { 
    console.log('IMIconnectPlugin.startup() Failed :' + JSON.stringify(error)); 
}); 
```

startupWithConfig

Initializes the SDK by using the config params appId, clientKey values that need to be defined by the developer.

Parameters:

Parameter

Type

Description

appId

String

The app id that is generated while creating an app asset within IMIconnect

clientKey

String

The client key that is generated while creating an app asset within IMIconnect

environment

String

(OPTIONAL) IMIconnect's server environment

serverDomain

String

(OPTIONAL) Sets your server domain (to override the zero-rating domain)

groupIdentifier

String

(OPTIONAL) The app group identifier. This group identifier is used to retrieve information between the CoreSDK and the NotificationServiceExtension. [Only for iOS]

allowUnencryptedDatabaseFallback

boolean

(OPTIONAL) If true, it allows creating a default SQLite database when SQLcipher fails.

IMIconnectPlugin.startupWithConfig(function(status) { 
    //result will be Boolean value. 
    console.log("IMIconnectPlugin.startupWithConfig(): " + result); 
}, function(error) { 
    console.log('IMIconnectPlugin.startupWithConfig() Failed :' + JSON.stringify(error)); 
}, appId, clientKey); //OPTIONAL environment, serverDomain, groupIdentifier, allowUnencryptedDatabaseFallback);

📘

Note:

This will be called by the plugin when the application is launched. So no need to call this method explicitly.

startupWithConfigOptions

Initializes the SDK by using the config jsonObject values that need to be defined by the developer.

Parameters:

Parameter

Type

Description

appId

String

The app id that is generated while creating an app asset within IMIconnect.

clientKey

String

The client key that is generated while creating an app asset within IMIconnect

environment

String

(OPTIONAL) IMIconnect's server environment

serverDomain

String

(OPTIONAL) Sets your server domain (to override the zero-rating domain)

groupIdentifier

String

(OPTIONAL) The app group identifier. This group identifier is used to retrieve information between the CoreSDK and the NotificationServiceExtension. [Only for iOS]

allowUnencryptedDatabaseFallback

boolean

(OPTIONAL) If true, it allows creating a default SQLite database when SQLcipher fails.

IMIconnectPlugin.startupWithConfigOptions(function(status) {  
            //result will be Boolean value.  
            console.log("IMIconnectPlugin.startupWithConfigOptions(): " + result);  
        }, function(error) {  
            console.log('IMIconnectPlugin.startupWithConfigOptions() Failed :' + JSON.stringify(error));  
        }, {  
            appId: "<APP_ID>",  
            clientKey: "<CLIENT_KEY>",  
            environment: "<SERVER_ENVIRONMENT>" 
            serverDomain: "<SERVER_DOMAIN>",  
            groupIdentifier: "<IOS_GROUP_IDENTIFIER>", 
            allowUnencryptedDatabaseFallback: "false" 
        });

shouldEnableMethodSwizzling (iOS Only)

Enables method swizzling for application life cycle methods and remote notifications methods based on shouldEnable parameter.

Parameters:

Parameter

Type

Description

shouldEnable

Boolean

The shouldEnable should set true to enable and false to disable method swizzling.

// For Enabling: 
IMIconnectPlugin.shouldEnableMethodSwizzling(function(status) {
    console.log("isMethodSwizzlingEnabled: " + status);
}, true);

// For Disabling: 
IMIconnectPlugin.shouldEnableMethodSwizzling(function(status) {
    console.log("isMethodSwizzlingEnabled: " + status);
}, false);

shouldEnableNotificationCenterDelegateSwizzling (iOS Only)

Sets User Notification Center Delegate in IMI SDK based on shouldEnable parameter value.

Parameters:

Parameter

Type

Description

shouldEnable

Boolean

The shouldEnable should set true to set and false to ignore User Notification Center Delegate.

// For Enabling: 
IMIconnectPlugin.shouldEnableNotificationCenterDelegateSwizzling(function(status) {
    console.log("shouldEnableNotificationCenterDelegateSwizzling: " + status);
}, true);

// For Disabling: 
IMIconnectPlugin.shouldEnableNotificationCenterDelegateSwizzling(function(status) {
    console.log("shouldEnableNotificationCenterDelegateSwizzling: " + status);
}, false);

startupLogger

This method is used to Initialize the logging system.

IMIconnectPlugin.startupLogger(
              function(result){
              //result will be Boolean value.
                  console.log(result);
              });

getSDKVersion


This method retrieves the SDK build version. Use the below code to call the getSDKVersion method.

IMIconnectPlugin.getSDKVersion()(
                    function(result){
                    //result will be String.
                        console.log(result);
                    }
            );

isStarted

This method is used to verify whether the SDK is started or not. Use the below code to call the isStarted method.

IMIconnectPlugin.isStarted(
                    function(result){
                    //result will be true if the SDK started, Otherwise false
                        console.log(result);
                    }
            );

📘

Note:

This is method is applicable only to the Android operating system.

shutdown

This method provides a means to shut down the SDK and perform the cleanup. After this method is called none of the SDK features will work. Use the below code to call the shutdown method.

IMIconnectPlugin.shutdown(
                  function(result){
                  //result will be Boolean value.
                      console.log(result);
                  }
              );

register

Registers the provided device profile with the imiconnect platform.

Parameters:

Parameters

Type

Description

deviceProfile

ICDeviceProfile

The device profile to register

Invoked on registration success or failure.

var deviceProfile = new ICDeviceProfile();
            deviceProfile.setAppUserId("9999");
            deviceProfile.setDeviceId("PROVIDE UNIQUE DEVICE ID");     
            IMIconnectPlugin.register(
                  function(resultJson){
                        console.log(resultJson);
                  },
                  function(error){
                        console.log(error);
                  }, 
                  deviceProfile );

📘

Note:

Default unique deviceId can be retrieved from imiconnect plugin using IMIconnectPlugin.getDefaultDeviceId() method.

For registering a device as a guest, refer to the below code snippet (Supports from 2.1.0 Plugin version).

var deviceProfile = new ICDeviceProfile();
deviceProfile.setAppUserId("9999");
deviceProfile.setDeviceId("PROVIDE UNIQUE DEVICE ID");
deviceProfile.setGuest(true);
IMIconnectPlugin.register(
function(resultJson) {
console.log(resultJson);
},
function(error) {
console.log(error);
}, deviceProfile);

getDeviceProfile

Returns the device profile information that is currently registered with the SDK. Returns null if no device is currently registered. Use the below code to call the getDeviceProfile method.

IMIconnectPlugin.getDeviceProfile (
                    function(icDeviceProfile){
                        console.log(icDeviceProfile);
                    }
            );

unregister

This method unregisters the current device profile from the imiconnect platform. Use the below code to call the unregister method.

IMIconnectPlugin.unregister(
                  function(result){
                      console.log(result);
                  },
                  function(error){
                      console.log(error);
                  }
          );

updateProfileData

Updates a parameter of the current device profile within the imiconnect platform.

Parameters:

Parameters

Type

Description

param

ICDeviceProfileParam

An ICDeviceProfileParam indicating the parameter which should be updated

value

String

A String containing the data value

IMIconnectPlugin.updateProfileData(
                    function(resultJson){
                        console.log(resultJson);
                    },
                    function(error){
                        console.log(error);
                    },
                    ICDeviceProfileParam.UserId, "9999"
            );
IMIconnectPlugin.updateProfileData(
                    function(resultJson){
                        console.log(resultJson);
                    },
                    function(error){
                        console.log(error);
                    },
                    ICDeviceProfileParam.CustomerId, "6666"
            );

removeProfileData

Removes a parameter of the current device profile from the imiconnect platform.

Parameters:

Parameters

Type

Description

param

ICDeviceProfileParam

The ICDeviceProfileParam representing the parameter data that should be removed

IMIconnectPlugin.removeProfileData(
                      function(resultJson){
                          console.log(resultJson);
                      },
                      function(error){
                          console.log(error);
                      },
                      ICDeviceProfileParam.UserId
              );
IMIconnectPlugin.removeProfileData(
                      function(resultJson){
                          console.log(resultJson);
                      },
                      function(error){
                          console.log(error);
                      },
                      ICDeviceProfileParam.CustomerId
              );

getDeviceId

This method returns the deviceId passed during registration. Use the below code to call the getDeviceId method.

IMIconnectPlugin.getDeviceId(
                      function(deviceId){
                          console.log(deviceId);
                      }
              );

isRegistered

This method is used to check whether the user is currently registered with imiconnect. Use the below code to call the isRegistered method.

Returns:
true if the device is registered, otherwise false.

IMIconnectPlugin.isRegistered(
                      function(result){
                          console.log(result);
                      }
              );

setPolicyPollingInterval

This method is used to set the interval (in minutes) at which the SDK will poll for policy updates. To prevent adverse effects on battery or CPU usage a minimum interval of 30 minutes is enforced.

Parameter

Type

Description

intervalMinutes

Integer

Specifies how the SDK will poll for policy updates.

The default value is 30 minutes.

IMIconnectPlugin.setPolicyPollingInterval(
                    function(result){
                        console.log(result);
                    }, intervalMinutes );

getPolicyPollingInterval

This method returns the current policy polling interval in minutes.

Returns: The policy polling interval in minutes.

IMIconnectPlugin.getPolicyPollingInterval(
                    function(result){
                        console.log(result);
                    });

setSecurityToken

This method is used to specify a Security Token that the plugin will pass to the imiconnect platform for user-centric API requests. The platform will validate the token before processing requests.

IMIconnectPlugin.setSecurityToken(function(result){
                        console.log(result);
                    },
                    function(error){
                        console.log(error);
                    }, token);

registerSecurityTokenExceptionListener

This method allows you to register an object, which implements the interface to listen for Security Token related exceptions which occur from internal (indirect) imiconnect platform API calls.

IMIconnectPlugin.registerSecurityTokenExceptionListener(
                    function(error){
                        console.log(error);
                    }
            );

unRegisterSecurityTokenExceptionListener

This method allows you to unregister a previously registered object which implements the ICSecurityTokenExceptionListener interface, in order to stop listening for Security Token exceptions.

IMIconnectPlugin.unRegisterSecurityTokenExceptionListener(
                    function(error){
                        console.log(error);
                    }
            );

getAppUserId

This method is used to get the App user ID. Use the below code to call the getAppUserId method.

IMIconnectPlugin.getDeviceProfile (
                    function(deviceProfile){                    
                        console.log(deviceProfile.getAppUserId();
                    }
            );

getCustomerId

This method is used to get the Customer ID. Use the below code to call the getCustomerId method.

IMIconnectPlugin.getDeviceProfile (
                    function(deviceProfile){                    
                        console.log(deviceProfile.getCustomerId();
                    }
            );

isAppUserSystemGenerated

This method is used to validate if userId is generated by the imiconnect system or not.

IMIconnectPlugin.getDeviceProfile (
                    function(deviceProfile){                    
                        console.log(deviceProfile.isAppUserSystemGenerated();
                    }
            );

getDefaultDeviceId

A convenient method for obtaining a device Id. The id returned is equivalent to Settings.Secure.ANDROID_ID(Android) and vendor ID of the device(IOS).

IMIconnectPlugin.getDefaultDeviceId (function (defaultDeviceId) {
            console.log(defaultDeviceId);
            }
     );

setLogOptions

This method sets the log options for the logger. Use the below code to call the setLogOptions method.

Parameter

Type

Description

logType

ICLogtype

The type of logs that will be logged.

logTarget

ICLogTarget

The target on which the logs will be displayed/recorded.

IMIconnectPlugin.setLogOptions(
                    function(result){
                        console.log(result);
                    },
                    function(error){
                        console.log(error);
                    },
                    ICLogType.Debug, ICLogTarget.Console );

setRetentionDuration

This method sets the retention duration of the logs. The logs will be kept during that duration and will be automatically purged after. Use the below code to call the setRetentionDuration method.

Parameter

Type

Description

days

Integer

Number of days after which the logs will be purged.

IMIconnectPlugin.setRetentionDuration(
                    function(result){
                        console.log(result);
                    },
                    retentionDuration // provide no of days retentionDuration
            );

getOutputLocation

This method returns the default output location. Use the below code to call the getOutputLocation method.

Return value: Returns absolute directory.

IMIconnectPlugin.getOutputLocation(
                    function(result){
                        console.log(result);
                    },
                    function(error){
                        console.log(error);
                    }
            );

📘

Note:

This method is applicable only to the Android operating system.

generatePin

This method is used to generate a pin and sent it to the user through SMS allowing him to authenticate with a pin than the traditional login/password. The phone number must be provided when creating a user profile

Parameter

Type

Description

userId

String

Specifies a user id or customer id (CRN and MSISDN) that are registered with imiconnect profile manager.

IMIconnectPlugin.generatePin(
                             function (result){ 
                                         console.log(result); 
                                         }, 
                                     function (error) { 
                                                 console.log(error); 
                                         }, 
                     userId);

ValidatePin

This method is used to validate the pin with the imiconnect platform.

Parameter

Tyoe

Description

pin

String

Specifies the pin number to be validated that is received as SMS.

userId

String

Specifies a user id or customer id (CRN and MSISDN) that are registered with imiconnect profile manager.

IMIconnectPlugin.validatePin(
                                function (result){ 
                                            console.log(result) 
                                            }, 
                                        function (error) { 
                                                    console.log(error); 
                                            }, 
                     pin, userId);