IMIconnect

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

Return TypeMethod
StringgetDeviceId()
Returns the device-Id passed during registration.

ICDeviceProfilegetDeviceProfile()
Returns the device profile that is curren-tly registered with the SDK. Returns null if no device is currently registered.

longgetPolicyPollingInterval()
Returns the interval, in minutes, at which the SDK will poll for policy updates.
StringgetSDKVersion()
Returns the SDK build version.
booleanisRegistered()
Returns true if the device is registered, otherwise returns false.
booleanisStarted()
Returns true if the SDK is started, otherwise returns false.
voidregister(final ICDeviceProfile deviceProfile, ICRegistrationCallback callback)
Registers the provided device profile with the Webex Connect platform.
voidregisterListener(ICSecurityTokenExceptionListener listener)
Registers an ICSecurityTokenExceptionListener that will be notified when Security Token related exceptions occur.
voidremoveProfileData(ICDeviceProfileParam param, ICUpdateProfileDataCallback callback)
Removes a parameter of the current device profile from the Webex Connect platform.
voidsetPolicyPollingInterval(int intervalMinutes)
Used to set the interval, in minutes, at which the SDK will poll for policy updates.
voidsetSecurityToken(String token)
Used to specify a Security Token that the SDK will pass to the Webex Connect platform for all user-centric API requests.
voidshutdown() - Deprecated
Please use shutdown(ICShutdownCallback) instead.
voidshutdown(ICShutdownCallback callback)
Used to cleanup internal resources used by the SDK.
voidstartup(Context context)
Initializes the SDK by reading configuration data from the application manifest.
voidstartup(Context context, ICConfig config)
Initializes the SDK by using the ICConfing object "config" that is to be defined by the developer.
voidstartup(Context context, ICStartupCallback callback)
Asynchronously initializes the SDK by reading configuration data from the application manifest
voidstartup(Context context, ICConfig config, ICStartupCallback callback)
Asynchronously initializes the SDK by using the ICConfing object "config" that is to be defined by the developer.
voidunregister(ICRegistrationCallback)
Unregisters the current device profile from the Webex Connect platform.
voidunregisterListener(ICSecurityTokenExceptionListener listener)
Unregisters a previously registered ICSecurityTokenExceptionListener instance.
voidupdateProfileData(ICDeviceProfileParam param, String value, ICUpdateProfileDataCallback callback)
Updates a parameter of the current device profile within the Webex Connect platform.
voidpublishEvent(Bundle eventParams, ICPublishEventCallback callback)
Invoke publishEvent to publish your custom events info to the Webex Connect platform.

getDeviceId

Returns the deviceId passed during registration.

Syntax: String getDeviceId()

getDeviceProfile

Returns the device profile that is currently registered with the SDK. Returns null if no device is currently registered.

Syntax: static getDeviceProfile()

getPolicyPollingInterval

Returns the current policy polling interval in minutes.

Syntax: int getPolicyPollingInterval()

Returns: The policy polling interval in minutes.

getSDKVersion

Returns the SDK build version.

Syntax: public String getSDKVersion()

Return value: SDK build version.

isRegistered

Used to determine if the device is currently registered with Webex Connect.

Syntax: boolean isRegistered()

Returns:** _true if the device is registered, otherwise _false*.

isStarted

Used to determine if the SDK is currently started.

Syntax: public boolean isStarted()

Returns: true if the SDK is started, otherwise false.

register

Registers the provided device profile with the Webex Connect platform.

Syntax: void register(final ICDeviceProfile deviceProfile, final ICRegistrationCallback callback)

Parameters:

ParametersTypeDescription
deviceProfileICDeviceProfileThe device profile to register
callbackICRegistrationCallbackInvoked on registration success or failure

Example:

IMIconnect.register(new ICDeviceProfile(ICDeviceProfile.getDefaultDeviceId()), new ICRegistrationCallback()
{
  @Override
  public void onRegistrationComplete(final Bundle bundle, final ICException exception)
  {
    if (exception != null) 
    {
      Log.e("Registration", "Registration failed! Reason:" + exception.toString());
    } 
    else 
    {
      Log.d("Registration", "Registration succeeded!");
    }
  }
});

📘

ICDeviceProfile contains a second constructor variant that allows you to specify a user id in addition to a device id. When a user id is not supplied, the Webex Connect platform will generate one, the generated value may be obtained by querying the ICDeviceProfile after a successful registration.

registerListener

Registers an ICSecurityTokenExceptionListener that will be notified when Security Token related exceptions occur.

Syntax: void registerListener(ICSecurityTokenExceptionListener listener)

Parameters:

ParameterTypeDescription
listenerICSecurityTokenExceptionListenerSecurity Token exception listener.

Example:

IMIconnect.registerListener(new ICSecurityTokenExceptionListener(){
  @Override
  public void onException(final ICException e)
  {
    switch (e.getErrorCode())
    {
      case TokenInvalid:
        // Token is invalid, regenerate 
      case TokenExpired:
        // Token has expired, regenerate 
      case TokenRequired:
				// Token is required, generate
						
        // Generate the token and pass back to the SDK
        // via IMIconnect.setSecurityToken(generatedToken);
    }
  }
});

removeProfileData

Removes a parameter of the current device profile from the Webex Connect platform.

Syntax: void removeProfileData(ICDeviceProfileParam param, final ICUpdateProfileDataCallback callback)

Parameters:

ParametersTypeDescription
paramICDeviceProfileParamThe ICDeviceProfileParam representing the parameter data which should be removed.
callbackICUpdateProfileDataCallbackThe callback through which the result of the operation is notified.

Example:

IMIconnect.removeProfileData(ICDeviceProfileParam.CustomerId, new ICUpdateProfileDataCallback()
{
  @Override
  public void onUpdateComplete(final Bundle bundle, final ICException exception)
  {
    if (exception != null) 
    {
      Log.e("removeProfileData", " removeProfileData for userId failed! Reason:" + exception.toString());
    } 
    else 
    {
      Log.d("removeProfileData", " removeProfileData for userId succeeded!");
    }
  }
});

setPolicyPollingInterval

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.

Syntax: void setPolicyPollingInterval(int intervalMinutes)

Parameters:

ParameterTypeDescription
intervalMinutesIntegerSpecifies how the SDK will poll for policy updates.

The default value is 30 minutes.

📘

To disable polling set the value to 0.

Polling only applies where both Push and In-App Messaging are not enabled.

setSecurityToken

Used to specify a Security Token that the SDK will pass to the Webex Connect platform for all user-centric API requests. The platform will validate the token before processing requests.

Syntax: void setSecurityToken(String token)

shutdown

Syntax:** void shutdown()

Deprecated - Please use shutdown(ICShutdownCallback) instead.

shutdown

Used to clean up internal resources used by the SDK. Invoking this method will stop all SDK features from functioning, In-app messages will no longer be received and Push notifications will no longer be handled.

Syntax: public void shutdown(final ICShutdownCallback callback)

IMIconnect.shutdown(new ICShutdownCallback()
{
  @Override
  public void onShutdownComplete()
  {
    Log.d("IMIconnect", "Shutdown Completed");
  }
});

📘

Normally usage of this method is not required, there are a few limited cases where you may wish to use it, such as if you are only using the Authentication or Monitoring features.

startup

Initializes the SDK by reading configuration data from the application manifest.

  Syntax: void startup(Context context)

  Parameters:

ParameterTypeDescription
contextContextSpecifies the Android context.

  Example:

public class MyApplication extends Application 
{
  @Override
  public void onCreate() 
  {
    super.onCreate();
    // Initialize the IMIconnect SDK , reads the configuration from app manifest
    try 
    {
      IMIconnect.startup(this);
    } 
    catch (ICException e) 
    {
      e.printStackTrace();
    }
  }
}
<application
   android:name="YOUR_APP_NAME"
   android:allowBackup="true"
   android:label="@string/app_name"
   android:theme="@style/AppTheme">

   <!-- Meta data needed for application identification -->
   <!-- Add the app id generated from imiconnect -->
   <meta-data
       android:name="appid"
       android:value="@string/app_id"/>

   <!-- Add the client key generated from imiconnect -->
   <meta-data
       android:name="clientkey"
       android:value="@string/client_key"/>

   <!-- Meta data needed for your Google GCM Project number -->
   <meta-data
       android:name="projectnumber"
       android:value="@string/project_number"/>
  
</application>

📘

Note

The startup method must be called from Application.onCreate so that the SDK is initialized in line with the lifecycle of the host application.

startup

Initializes the SDK by using the ICConfing object "config" that is to be defined by the developer.

Syntax: void startup(Context context, ICConfig config)

  Parameters:

ParameterTypeDescription
contextContextSpecifies the Android context.
configICConfigAn ICConfig instance containing valid app credentials.

  Example:

public class MyApplication extends Application 
{
  @Override
  public void onCreate() 
  {
    super.onCreate();

    try 
    {
    //Initialize an ICConfig instance with an appId and clientKey.
    ICConfig config = new ICConfig(appId, clientKey);
    // Initialize the IMIconnect SDK with ICConfig instance
    IMIconnect.startup(this, config);
    } 
    catch (ICException e) 
    {
      e.printStackTrace();
    }
  }
}

startup

Initializes the SDK by reading configuration data from the application manifest. This methods perform all of their work on a background thread. Once startup is complete, or if an error occurs, the callback will be invoked to report the result of the operation. Please note that the callback is invoked on the main thread, as such you should not perform any long running operation within the callback.

Syntax: static void startup(Context context, ICStartupCallback callback)

Parameters:

ParameterTypeDescription
contextContextRefer to Android context.
callbackICStartupCallbackRefer to ICStartupCallback

Example:

IMIconnect.startup(context, new ICStartupCallback() 
                   { 
                     @Override 
                     public void onStartupComplete(ICException exception) 
                     { 
                       if (exception != null) 
                       { 
                         //Startup failed, inspect exception for more information 
                       } 
                      //Startup succeeded, other SDK methods may now be called 
                     } 
                   });

<application
   android:name="YOUR_APP_NAME"
   android:allowBackup="true"
   android:label="@string/app_name"
   android:theme="@style/AppTheme">

   <!-- Meta data needed for application identification -->
   <!-- Add the app id generated from imiconnect -->
   <meta-data
       android:name="appid"
       android:value="@string/app_id"/>

   <!-- Add the client key generated from imiconnect -->
   <meta-data
       android:name="clientkey"
       android:value="@string/client_key"/>

   <!-- Meta data needed for your Google GCM Project number -->
   <meta-data
       android:name="projectnumber"
       android:value="@string/project_number"/>
  
</application>

📘

Note

The startup method must be called from Application.onCreate so that the SDK is initialized in line with the lifecycle of the host application.

startup

Initializes the SDK by using the ICConfing object "config" that is to be defined by the developer.
This methods perform all of their work on a background thread. Once startup is complete, or if an error occurs, the callback will be invoked to report the result of the operation. Please note that the callback is invoked on the main thread, as such you should not perform any long running operation within the callback.

Syntax: static void startup(Context context, ICConfig config, ICStartupCallback callback)

Parameters:

ParameterTypeDescription
contextContextSpecifies the Android context.
configICConfigAn ICConfig instance containing valid app credentials.
callbackICStartupCallbackRefer to ICStartupCallback

Example:

//Initialize an ICConfig instance with an appId and clientKey. 
ICConfig config = new ICConfig(appId, clientKey); 
IMIconnect.startup(context, config, new ICStartupCallback() 
                   { 
                     @Override public void onStartupComplete(ICException exception) 
                     { 
                       if (exception != null) 
                       { 
                         //Startup failed, inspect exception for more information 
                       } 
                       //Startup succeeded, other SDK methods may now be called 
                     } 
                   });

unregister

Unregisters the current device profile from the Webex Connect platform. On successful completion, Push and In-App Messages will no longer be received on the device.

Syntax: void unregister(final ICRegistrationCallback callback)

Parameters:

ParametersTypeDescription
callbackICRegistrationCallbackInvoked to report operation success or failure

unregisterListener

Unregisters a previously registered ICSecurityTokenExceptionListener instance. The instance will no longer receive Security Token exceptions.

Syntax: unregisterListener(ICSecurityTokenExceptionListener listener)

Parameters:

ParameterTypeDescription
listenerICSecurityTokenExceptionListenerSecurity Token exception listener.

updateProfileData

Updates a parameter of the current device profile within the Webex Connect platform.

Syntax: void updateProfileData(ICDeviceProfileParam param, final String value, final ICUpdateProfileDataCallback callback)

Parameters:

ParametersTypeDescription
paramICDeviceProfileParamAn ICDeviceProfileParam indicating the parameter which should be updated.
valueStringA String containing the data value.
callbackICUpdateProfileDataCallbackA callback through which the result of the operation is notified.

Example:

IMIconnect.updateProfileData(ICDeviceProfileParam.CustomerId, customerIdValue, new ICUpdateProfileDataCallback()
  {
  @Override
  public void onUpdateComplete(final Bundle bundle, final ICException exception)
    {
      if (exception != null) 
      {
        Log.e("updateProfileData", "updateProfileData for customerId failed! Reason:" + exception.toString());
      } 
      else 
      {
        Log.d("updateProfileData", "updateProfileData for customerId succeeded!");
      }
    }
  });

publishEvent

Invoke publishEvent to publish your custom events info to the Webex Connect platform.

Syntax: void publishEvent(Bundle eventParams, ICPublishEventCallback callback)

Parameters:

ParemetersTypeDescription
eventParamsBundleYour custom events input.
callbackICPublishEventCallbackA callback through which the result of the operation is notified.

Example:

Bundle bundle = new Bundle();
bundle.putString("number", "9123443212");
bundle.putString("OTP", "234642");
IMIconnect.publishEvent(bundle, new ICPublishEventCallback()
{
   @Override
   public void onPublishEventComplete(final Bundle bundle, final ICException exception)
   {
      if (exception != null)
      {
         Log.e(TAG, "Publish failed", exception);
         return;
      }
      Log.d(TAG, "Published successfully");
   }
});