IMIconnect Developer Hub

Welcome to the IMIconnect developer hub. You'll find all the resources to help you get started with IMIconnect quickly. We are here to support you if you get stuck. Let's jump right in!

Get Started

Cordova Plugin

Cordova Installation

  1. To setup the Cordova plugin in your machine, you are required to install npm and Node in your machine.
  2. Once you have npm installed, install the Cordova in your machine using the following command.
     $ npm install -g cordova
    
  3. Create a Cordova application by executing the command.
    $ cordova create myapp com.mycompany.myapp MyApp
    

In the command above, myApp is the directory name, MyApp is the application name and com.mycompany.myapp is the package name. For more details refer to this link.

Android Installation for Cordova

After you have created the Application successfully, add the Android platform to the application.

  1. Navigate to the application folder and execute the below command.
      $ cordova platform add android
    
    This will create a folder with the name android inside the application path myApp/platforms.
  2. Create the .apk file to test the application using the following command
         $ cordova build android
    
    Executing the above command will create .apk file with the name android.debug.apk inside the application path myApp/platforms/android/build/outputs/apk
  3. The application is ready to execute. To run the application, start a new AVD(Android Virtual Device) with the following command
         $ android avd
    
    • On executing the command, a pop-up screen is displayed to create a new virtual device.
    • Execute the below command to start the emulator and run the .apk file in the emulator
         $ cordova emulate android
      
    • Now add the custom plugin to the application.
      Navigate to the cordova application folder(i.e myapp) and execute the below command.
         $ cordova plugin add <local plugin dir>
      
      Example :
      $ cordova plugin add IMIconnectPlugin
    • To list all the plugins installed in your machine use the following command
         $ cordova plugin list
      
    • To remove a particular plugin from the application follow the below command.
         $ cordova plugin remove plugin_name
      

Android Local Setup

  1. Open android.manifest file and add the below tags inside the manifest tag.
    <permission android:name="{ Name of your package}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> 
    <uses-permission android:name="{ Name of your package}.permission.C2D_MESSAGE" />
    
    Example:
    <permission android:name="io.cordova.hellocordova.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
    <uses-permission android:name="io.cordova.hellocordova.permission.C2D_MESSAGE"/>
    
  2. Open build.gradle file and add the below tags inside the buildScript -> dependencies
  3. Get the google-services.json file from firebase and copy the same in platforms -> androidlocation.
  4. Configure the appId and clientKey in string.xml which is available in android/res/values/string.xml, as shown below
    <string name="app_id">YOUR APPID</string>
     <string name="client_key">YOUR CLIENT KEY</string>
    
    5.Now that the application is ready, create the .apk file to test the application by executing the following command.
       $ cordova build android
    

Installing the Requirements for iOS

Xcode

  1. To continue with the application setup, install Xcode in your machine. If Xcode is not installed you can find the Xcode in two different ways.

    • From the App Store, available by searching for "Xcode" in the App Store application.
    • From Apple Developer Downloads, which requires registration as an Apple Developer.
  2. Once Xcode is installed, several command-line tools need to be enabled for Cordova to run. From the command line, run:

          $ xcode-select --install
    

Deployment Tools

The ios-deploy tools allow you to launch iOS apps from an iOS device. On the command-line, execute the following command to install ios-deploy.

   $ npm install -g ios-deploy

iOS Installation for Cordova

Add pinned version of the iOS platform and save the downloaded version to config.xml & package.json

$ cordova platform add ios

Adding plug-in

  1. To add custom plug-in to the application; navigate to the cordova application folder(myApp) and executive the following command.
    $ cordova plugin add IMIconnectPlugin
    
    in the example above, IMIconnectPlugin is the plug-in** name.
  2. Use the following command to build the Cordova application.
    $ cordova build ios
    

Project Setup

To deploy your Cordova application in the iOS simulator

  1. Open the workspace file (../platforms/ios/MyApp.xcworkspace) in Xcode. or you can use the below command line to open the workspace file:
    $ open ./platforms/ios/MyApp.xcworkspace/
    
  2. After opening the workspapce file, Make sure the MyApp project is selected in the left panel.
    Note: Refer Quickstart Guide to create p12 file using the same identifier.
    • After Creating the P12 file. In Application, switch on the PushNotifications from Capabilities tab on main window.
    • Switch ON the Background Modes, and checkmark the 'Remote notifications' in the capabilities tab.
  3. On the main window, select General tab and provide the Bundle Identifier(you can change this as per your requirement) and Signing Details.
  4. Now give the following Framework status as optional in Linked Frameworks and Libraries section in the same General tab.
    • FileProvider.Framework
    • IOSurface.framework
    • UserNotificationUI.framework
    • UserNotifications.framework
    • IMIconnectNotificationServiceExtension.framework
  5. Remove IMIconnectNotificationServiceExtension.framework from Linked Frameworks and Libraries , and add it on Embedded Binaries
  6. In order to receive the notifications, enable the Bluetooth permission.
    Go to info tab and click the + icon anywhere on the displayed list. Enter the key as Privacy - Bluetooth Peripheral Usage Description and value as $(PRODUCT_NAME) Bluetooth Peripheral use.
  7. In order to receive Rich Push Notifications, add NotificationService Extension.
    a.Target on pressing "(+)" icon which is available on target section,
    b. Refer Add Notification service for adding extension Target.
  8. When adding Extension, you will notice a New Folder in your project hierarchy containing three new files NotificationService.h NotificationService.m and Info.plist**.
    • Add IMIconnectNotificationServiceExtension.framework manually in the new Folder, the file is available at plugin/src/ios/lib
    • In Info.Plist of your new notificationextension Target , add App Transport Security Setting Dictionary with Allow Arbitrary Loads; Bool value YES by selecting +.
  9. On the General Tab,->Linked Frameworks and Libraries, set "IMIconnectNotificationServiceExtension.framework" status as optional.
  10. Now create a Group Identifier, refer create-an-app-group section in Quickstart Guide for more information
  11. Switch ON the AppGroups, then checkmark your group identifier in the capabilities tab. from main project target, Extension Target as well.

  12. Finally, connect the mobile (device) to your machine to see the connected device on the Scheme menu.

  13. Click Run button from the same toolbar to the left of the Scheme to build, deploy, and executive the application on the connected device.
    Now you can see your application is running on the device.

iOS Local Setup

  1. Copy the following files to your project's plug-ins folder:
    AppDelegate+imiConnect.h
    AppDelegate+imiConnect.m
    IMIconnectPlugin.h
    MIconnectPlugin.m
    

NOTE

Add other dependent frameworks files.

  1. Add a reference for this plugin to the plugins section in the config.xml file.
    <feature name="IMIconnectPlugin">
     <param name="ios-package" value="IMIconnectPlugin"/>
    </feature>
    

App Configuration setup

  1. Add appId, clientKey & groupIdentifier in application info.plist.
Applicaiton level plist

Applicaiton level plist

  1. Start the SDK in your main startup view controller by using the sample code below.
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    //Password to generate encryption key for secure preferences
    IMIconnectPlugin *pushHandler = [self getCommandInstance:@"IMIconnectPlugin"];
    pushHandler.password = @"setYourPassword";
    
    //DK initializing
    NSDictionary *infoPlistDict = [[NSBundle mainBundle] infoDictionary];
    NSDictionary *RootDict = infoPlistDict[@"Root"];
    NSString *clientkey = RootDict[@"clientKey"];
    NSString *appId = RootDict[@"appId"];
    ICConfig *icConfig = [[ICConfig alloc] initWithClientKey:clientkey forAppId:appId];
  
    NSError *error;
    [IMIconnect startupWithConfig:icConfig error:&error];
}

Core


This section details the classes which facilitate SDK initialization, registration and the logging system

IMIconnectPlugin

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 exception to the Authentication module, it is also necessary to register a user before other features are used.

startup

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

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

startupWithConfig

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

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.

NOTE: And this method is called by the plugin when the application is launched. So no need to call this method explicitly.

IMIconnectPlugin.startupWithConfig(
              function(result){
                  console.log(result);
              },
              function(error){
                  console.log(error);
              }, 
			  appId, clientKey ); 

startupLogger

This method is used to Initialize the logging system.

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

getSDKVersion:

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


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

isStarted

This method is used to verify whether the SDK has started or not. Use the below method to check the status of the SDK.

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

shutdown

This method provides a means to shutdown the SDK and to perform cleanup. Once this method is called, none of the SDK features will work. Use the below method to call the Shutdown.

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

register

Registers the provided device profile with the IMIconnect platform.

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(result){
                        console.log(result);
                  },
                  function(error){
                        console.log(error);
                  }, 
                  deviceProfile ); 

Note : Default unique deviceId can be retrived from connect plugin using IMIconnectPlugin.getDefaultDeviceId() method.

For registering a device as guest, refer to the below code snippet

var deviceProfile = new ICDeviceProfile();
deviceProfile.setAppUserId("9999");
deviceProfile.setDeviceId("PROVIDE UNIQUE DEVICE ID");
deviceProfile.setGuest(true);
IMIconnectPlugin.register(
 function(jsonObj) {
 console.log("Registration Succeeded : " + JSON.stringify(jsonObj));
 },
 function(errJsonObj) {
 console.log(JSON.stringify(errJsonObj));
 }, deviceProfile);

getDeviceProfile

This method returns the device profile information that is currently registered with the SDK. Returns null if no device is currently registered.

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

unregister

This method unregisters the current device profile from the IMIconnect platform. Use the below script 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
Type
Description

param

ICDeviceProfileParam

An ICDeviceProfileParam indicating the parameter which should be updated.

value

String

A String containing the data value.

Update userId:

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

Update customerId:

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

removeProfileData

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

Parameters
Type
Description

param

ICDeviceProfileParam

The ICDeviceProfileParam representing the parameter data which should be removed.

Remove userId:

              IMIconnectPlugin.removeProfileData(
                      function(result){
                          console.log(result);
                      },
                      function(error){
                          console.log(error);
                      },
					  ICDeviceProfileParam.UserId
              );
			  
Remove customerId :

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

getDeviceId

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

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

isRegistered

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

Returns: Retunstrue 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) connect 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);
                    }
);

setLogOptions:

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

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 method to call the setRetentionDuration.

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 method to call the getOutputLocation.

Return value: Returns absolute directory.

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

allowJavascriptInWebviews

This method allows JavaScript execution within WebView instances that are created by the SDK. The default value is false.

Parameter
Type
Description

flag

Boolean

True if WebView Javascript execution is allowed.

            IMIconnectPlugin.allowJavascriptInWebviews(
                    function(result){
                        console.log(result);
                    }, 
                    true
            ); 

isMessageStarted

This method is used to verify the status of the ICMessaging (started or not)

Return Value: Returns a boolean value whether ICMessaging has started or not.

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

connect

This method is used to establish a connection to receive Real Time Messages from IMIconnect platform. Use the below code to call the connect method.

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.

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

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. Use the below method to call the disconnect.

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

fetchTopics

To get a list of topics that are configured with IMIconnect, you need to send the offset using the following javascript code

Parameter
Type
Description

offset

Integer

Passes an offset value to fetch topics from that offset value.

var offset = 0;
IMIconnectPlugin.fetchTopics(function(topics, hasMoreData) {
 var log = "[";
 for (var i = 0; i < topics.length; i++) {
 log += topics[i].getName() + ", ";
 }
 log += "]";
 console.log("Topics: " + log + ", hasMoreData: " + hasMoreData);
}, function(errJsonObj) {
 console.log("Error : " + JSON.stringify(errJsonObj));
}, offset);

subscribeTopic

To subscribe to the topic allowing the SDK to receive messages on that topic, you need to send the TopicId using the following javascript code

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

unsubscribeTopic:

To unSubscribe to the topic allowing the SDK to receive messages on that topic, you need to send the TopicId using the following javascript code

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

connectionStatusChangedListener

This listener is used for activating the connection status change listener between SDK and IMIconnect platform.

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

getConnectionStatus :

This method is used to get the current connection status between the SDK and IMIconnect platform.

Return Value: Returns the current connection status between the SDK and the IMIconnect platform.

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

createThread

This method creates a Thread with thread object param for users using the following javascript code.

 var thread = new ICThread();
 thread.setTitle("MyTitle");
 thread.setCategory("MyCategory");
 IMIconnectPlugin.createThread(function (thread) {
                                  window.alert(thread.getTitle());}, function (error) {  console.log(error); }, thread);

Note

updateThread:

This method is used to update a thread.

Parameter
Type
Description

thread

ICThread

Update the passed Thread(Instance of ICThread).

IMIconnectPlugin.updateThread(function (thread) {
                                  window.alert(thread.getTitle());}, function (error) {  console.log(error); }, thread);

closeThread

This method is used to close the thread.

Parameter
Type
Description

thread

ICThread

Close the passed Thread(Instance of ICThread).

IMIconnectPlugin.closeThread(function (thread) {
                                  window.alert(thread.getTitle());}, function (error) {  console.log(error); }, thread);
                                  

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.

Parameter
Type
Description

beforeDate

Date

Pass value to fetch Threads before that Date

limit

Integer

Pass value to limit the fetching thread count

var beforeDate = new Date();
var limit = 30;
IMIconnectPlugin.fetchThreads(function(threads, hasMoreData) {
 var log = "[";
 for (var i = 0; i < threads.length; i++) {
 log += threads[i].getTitle() + ", ";
 }
 log += "]";
 console.log("Threads: " + log + ", hasMoreData: " + hasMoreData);
}, function(errJsonObj) {
 console.log("Error: " + JSON.stringify(errJsonObj));
}, beforeDate, limit);

fetchTopics

This method is used to get a list of topics that are configured with IMIconnect app. Use the filter parameter to control the type of topics that are returned.

IMIconnectPlugin.fetchTopics(function (topics) {
                             var text = "";
                             for (var i = 0; i < topics.length; i++) {
                             text += topics[i].getName() + "<br>";
                             }
                             window.alert(text)
                             
                             }, function (error) {  console.log(error); },{ "offset": 0 });	

publishMessage

This method is used to publish the passed ICMessage instance through RTM connection.

Parameter
Type
Description

message

ICMessage

Refer to ICMessage JS class.

var message = new ICMessage();
        message.setMessage("Test Message");
		message.setThread(thread);
IMIconnectPlugin.publishMessage(function (icMessage) {
                                    console.log(JSON.stringify(icMessage.toJSON()));
                                     }, function (error) {  console.log(error); }, message);

setMessageSyncPolicy

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

Parameter
Type
Description

policy

ICMessageSynchronizationPolicy

Message synchronization policy object. refer ICMessageSynchronizationPolicy JS class.

var syncPolicy = new ICMessageSynchronizationPolicy();
    syncPolicy.setMode(ICMessageSynchronizationMode.Limited);
    syncPolicy.setLimits(10,20);    // maxThreads - 10, maxMessagesPerThread - 20
    IMIconnectPlugin.setMessageSyncPolicy(
									function (result) 
									{ window.alert(result); },
									syncPolicy);		

MessageListener

Interface for listening to incoming messages

IMIconnectPlugin.messageListener(

            function(messages) {

 

                               var text = "";

                               for (var i = 0; i < messages.length; i++) {

                               text += messages[i].getMessage() + "<br>";

                               }

                               console.log(text);
 

            });

DeepLinkListener

Interface for listening deep link actions


        IMIconnectPlugin.deeplinkListener(function(resultJson) {

                console.log('deeplinkListener  : ' + JSON.stringify(resultJson));


 

            });

fetchMessages:

This method is used to get a list of messages from the Connect platform.

Parameter
Type
Description

beforeDate

Date

Specifies the date before the messages needs to returned.

limit

Integer

Pass value to limit the fetching message count.

threadId

string

Specifies the value of ThreadId.

var threadId = "Thread ID";
var beforeDate = new Date();
var limit = 30;
IMIconnectPlugin.fetchMessages(function(messages, hasMoreData) {
 var log = "[";
 for (var i = 0; i < messages.length; i++) {
 log += messages[i].getMessage() + ", ";
 }
 log += "]";
 console.log("messages: " + log + ", hasMoreData: " + hasMoreData);
}, function(errJsonObj) {
 console.log("Error: " + JSON.stringify(errJsonObj));
}, beforeDate, limit, threadId);

setMessageAsRead

This method is used to update the status of the message identified by transactionId as Read.

Paramter
Type
Description

transactionId

String

Specifies a single transaction id.

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

setMessagesAsRead

To set multiple messages as read pass array of transactionIds separated by comma (,)

Parameter
Type
Description

transactionIds

String

Specifies an array of transaction ids.

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

uploadFile

This method is used to upload a file to IMIconnect platform.

Paramters
Type
Description

filePath

String

local file path to be uploaded

IMIconnectPlugin.uploadFile(
						function (resultJSObject) { console.log(resultJSObject);  },
						function (error) {  console.log(error); },
						filePath);	

isFileUploading

This method is used to check if the manager is currently uploading a file

Parameter
Type
Description

filePath

String

The local file to be checked.

Return Value: True if the file is currently being uploaded.

IMIconnectPlugin.isFileUploading(
							function (status) { console.log(status);  },
							filePath);	

downloadFile

This method is used to download a file from URL.

Parameter
Type
Descripition

fileUrl

String

The URL of the file to be downloaded.

IMIconnectPlugin.downloadFile(
							function (resultJSObject) { console.log(resultJSObject);  },
							function (error) {  console.log(error); },
							fileUrl);
              
              

isFileDownloading:

This method is used to check if the manager is currently downloading a file at a URL.

Parameter
Type
Description

fileUrl

String

The URL of the file that will be checked.

IMIconnectPlugin.isFileDownloading(
								function (status) { console.log(status);  }, 
								fileUrl);

getCachedFile

This method is used to check if a file exists for a URL.

Parameter
Type
Description

fileUrl

String

The URL of the file that will be checked.

IMIconnectPlugin.getCachedFile(
								function (filePath) { console.log(filePath);  }, 
								function (error) {  console.log(error); },
								fileUrl);

saveMessage

This method saves single ICMessage

Parameter
Type
Description

message

ICMessage

The ICMessage to be saved

Return Value: Returns true if message storage completes, false Otherwise

IMIconnectPlugin.saveMessage(function (status) { console.log(status);  }, function (error) {  console.log(error); }, message);

saveMessages

This method saves multiple ICMessages

Parameter
type
Description

messages

ICMessage[]

The array of ICMessages to be saved

Return Value: Returns true if message storage completes, false Otherwise

IMIconnectPlugin.saveMessages(function (status) { console.log(status);  }, function (error) {  console.log(error); }, messages);

loadMessage

This method loads single ICMessage from local storage based on transactionId.

Parameter
Type
Description

transactionId

String

The transactionId to retrieve from local storage

Return Value: Returns ICMessage instance if message exists with transactionId

IMIconnectPlugin.loadMessage(function (message) {
                             console.log(message.getMessage()); 
                             }, function (error) {  console.log(error); }, transactionId);

loadMessages

This method Loads ICMessages from local storage based on threadId and submitted date with a specific limit

Parameter

threadId

String

The threadId to be retrieved from local storage

submittedBefore

Date

The submittedBefore to be used to fetch messages before submittedBefore from local storage

submittedAfter

Date

The submittedAfter to be used to fetch messages after submittedAfter from local storage

limit

Integer

The limit to be used to fetch limited number of messages from local storage

Return Value: Returns array of ICMessage instance if message exists with threadId.

MIconnectPlugin.loadMessages(function (messages) {
                              var text = "";
                              for (var i = 0; i < messages.length; i++) {
                              text += messages[i].getMessage() + "<br>";
                              }
							  console.log(text);                              
                              }, function (error) {  console.log(error); },threadId, submittedBefore,submittedAfter, 30);

deleteMessageFromStore

This method allows you to delete single ICMessages from local storage based on transactionId

Parameter
Type
Description

transactionId

String

The transactionId to be deleted from local storage

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

IMIconnectPlugin.deleteMessageFromStore(function (status) {
                               console.log(status);
                               }, function (error) {  console.log(error); }, transactionId);

getMessageCount

This method provides the count of messages from local storage based on threadId.

Parameter
Type
Description

threadId

String

The threadId to be fetched count from local storage

Return Value: Returns count of messages.

IMIconnectPlugin.getMessageCount(function (count) {
                                 console.log(count);
                                 }, function (error) {  console.log(error);
                                                     
   },threadId);

saveThread

This method saves single ICThread

Parameter
Type
Description

thread

ICThread

The ICThread to be saved

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

var thread = new ICThread();
 thread.setTitle(threadName);
 IMIconnectPlugin.saveThread(function (status) {
                                console.log(status);
                                },function (error) {  console.log(error); }, thread);

saveThreads

This method saves multiple ICThreads

Parameter
Type
Description

threads

ICThread[]

The array of ICThreads to be saved

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

var threads = [];
        var thread = new ICThread();
        thread.setTitle(threadName);
		threads.push(thread);
		IMIconnectPlugin.saveThreads(function (status) {
                                console.log(status);
                                }, function (error) {  console.log(error); }, 
    threads);
  

loadThread

This method loads single ICThread from local storage based on threadId

Parameter
Type
Description

threadId

String

The threadId to be retrieved from local storage

Return Value: Returns ICThread instance if thread exists with threadId.

IMIconnectPlugin.loadThread(function (thread) {
                            console.log(thread.getTitle())
                            }, function (error) {  console.log(error); }, threadId);


loadThreads

This method Loads ICThreads from local storage based date modifiedBefore with specific limit

Parameter
Type
Description

modifiedBefore

Date

The modifiedBefore(Date instance) to be used to fetch threads modified before from local storage

modifiedAfter

Date

The modifiedAfter(Date instance) to be used to fetch threads modified after from local storage

limit

Integer

The limit to be used to fetch limited number of threads from local storage

Return Value: Returns array of ICThreads instance, if threads exists between before & after the modified date with limit.

IMIconnectPlugin.loadThreads(function (threads) {
                             
                             var text = "";
                             for (var i = 0; i < threads.length; i++) {
                             text += threads[i].getTitle() + "<br>";              
                             }
                             console.log(text);
                             }, function (error) {  console.log(error); }, modifiedBefore, modifiedAfter,30);

loadUnreadThreads

This method loads unread ICThreads from local storage with specific limit.

Paramter
Type
Description

limit

Integer

The limit to be used to fetch limited number of unread threads from local storage

Return Value: Returns array of Unread ICThreads instance with limit.

IMIconnectPlugin.loadUnreadThreads(function (threads) {
                                   var text = "";
                                   for (var i = 0; i < threads.length; i++) {
                                   text += threads[i].getTitle() + "<br>";
                                   }
									console.log(text);
                                   }, function (error) {  console.log(error); }, 30);

deleteThread

This method deletes single ICThread from local storage based on threadId

Parameter
Type
Description

threadId

String

The threadId to be deleted from local storage

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

IMIconnectPlugin.deleteThread(function (status) {
                              console.log(status);
                              }, function (error) {  console.log(error); }, 
 threadId);
               
 

getThreadCount

This method gives total number of threads count from local storage.

Return Value : Returns count of threads

IMIconnectPlugin.getThreadCount(function (count) {
                                 console.log(count);
                                 }, function (error) {  console.log(error); });

getUnReadThreadCount

This method gives count of unRead messages threads count.

Return Value: Returns count of unRead messages threads count.

IMIconnectPlugin.getUnReadThreadCount(function (count) {
                                       console.log(count);
                                       }, function (error) {  console.log(error); });

deleteAll

This method deletes complete threads & messages.

Return Value: Returns true if delete completes, false Otherwise

MIconnectPlugin.deleteAll(function (status) {
                           console.log(count);
                           }, function (error) {  console.log(error); });

publishEvent

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

var eventJsonObj = JSON.parse("{\"name\":\"John\",\"age\":30,\"city\":\"New
York\"}");
IMIconnectPlugin.publishEvent(function(jsonObj) {
 console.log("Successful: " + JSON.stringify(jsonObj));
 },
 function(errJsonObj) {
 console.log("Failed: " + JSON.stringify(errJsonObj));
 }, eventJsonObj);

publishTypingIndicator

Facilitates publication of typing start/stop indicator events to the IMIconnect platform.

 var threadId = "Your thread id";
 var isIndicatorEnabled = true;
 IMIconnectPlugin.publishTypingIndicator(function(status) {
 console.log("Successfully published typing indicator: " + status);
 },
 function(errJsonObj) {
 console.log("Error: " + JSON.stringify(errJsonObj));
 }, threadId, isIndicatorEnabled);

deleteMessage

Invoke deleteMessage to delete the given message transaction id from the IMIconnect platform.

var messageTransactionId = "Your message's transaction id";
IMIconnectPlugin.deleteMessage(function(id) {
 console.log("Deleted successfully: " + id);
 },
 function(errJsonObj) {
 console.log("Error: " + JSON.stringify(errJsonObj));
 }, messageTransactionId);

ICDeviceProfile

getAppUserId

This method is used to get the App user ID. Use the below script 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 script 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 IMIconnect system or not.

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

getDefaultDeviceId

Convenience 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 : ' + defaultDeviceId);
});

ICMessage


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

isOutgoing

This method is used to verify whether a message is outgoing or not.

Syntax:boolean isOutgoing()

Return Value: Returns true if message is outgoing.

getTitle

This method is used to get the message notification title.

Syntax: String getTitle()

Return Value: Returns message notification title.

getCategory

This method is used to get the category of the interactive message.

Syntax: String getCategory()

Return Value: Returns the category of the message.

getChannel

This method is used to get the channel on which the message was received.

Syntax: String getChannel()

Return Value: Returns the channel.

getCustomTags

This method is used to get the custom or developer specified data that was sent as part of the message payload.

Syntax: JSObject getCustomTags()

Return Value: Returns the data that was sent along with the message payload.

getExtras

This method is used to get the supplementary data that was sent as part of the message payload. The format of this data is controlled by IMIconnect platform.

Syntax: JSObject getExtras()

Return Value: Returns the supplementary data that was sent along with the message payload.

getMessage

This method is used to get the content of the message that is displayed to the end users.

Syntax: String getMessage()

Return Value: Returns the text message that is displayed to the end users.

getPriority

This method is used to get the priority set to the message.

Syntax: String getPriority()

Return Value: Returns the priority of the text message.

getReference

This method is used to get the message reference to trigger a rule set in IMIconnect.

Syntax: String getReference()

Return Value: Returns the reference of the message.

getTransactionId

This method is used to get the transaction id that uniquely identifies the message transaction within the IMIconnect platform.

Syntax: String getTransactionId()

Return Value: Returns the transaction id that identifies the message transaction.

getUserId

This method is used to get the user id from which the message is originated. This method is not applicable to Push messaging.

Syntax: String getUserId()

Return Value: Returns the user id from which the message is originated.

setCustomTags

This method is used to set the custom tags object to be sent with an outgoing RTM. This method is not applicable to Push messaging.

Syntax: void setCustomTags(tags)

Parameter
Type
Description

tags

JSObject

Specifies the JSObject.

setMessage

This method is used to set the content of the text message to be sent with an outgoing RTM. This method is not applicable to Push messaging.

Syntax: void setMessage(message)

Parameter
Type
Description

message

String

Specifies the content of the text message.

getAttachments

This method is used to get the attachment files that are attached to the message.

Syntax: ICAttachment[] getAttachments()

Return Type: Returns the attachment files attached to the message.

getThread

This method is used to get the thread details specified in the message.

Syntax: ICThread getThread()

Return Type: Returns the thread details that were specified in the message.

getSubmittedAt

This method is used to get the message submitted date to the Connect platform.

Syntax: String getSubmittedAt()

Return Type: Returns the message submitted date to the Connect platform.

getDeliveredAt

This method is used to get the message delivered date to the device.

Syntax: String getDeliveredAt()

Return Type: Returns the message delivered date to the device.

getReadAt

This method is used to get the message read date to the device.

Syntax: String getReadAt()

Return Type: Returns the message read date to the device.

getType

This method is used to get the message type.

Syntax: ICMessageType getType()

Return Type: Returns the message type.

setAttachments

This method is used to set the media file attachments to be sent with an outgoing RTM. This method is not applicable to Push messaging.

Syntax: void setAttachments(final ICAttachment[] attachments)

Parameter
Type
Description

attachments

Refer to ICAttachment class.

setThread

This method is used to set the thread details that need to be specified in the message.

Syntax: void setThread(final ICThread thread)

Parameter
Type
Description

Thread

ICThread

Refer to ICThread class.

getStatus

This method allows to get the message status such as None/Sent/NotSent/Delivered/Read

Syntax: ICMessageStatus getStatus()

Return Value: Returns the ICMessageStatus class.

setStatus

This method allows to set message status such as None/Sent/NotSent/Delivered/Read

Syntax: void setStatus(ICMessageStatus status)

Parameter
Type
Description

status

set message status

ICAttachment


This class exposes data relating to attachments that are received through RTM or Push. In addition, it is used to attach media and location to outgoing RTM messages.

getContentType

This method is used to get the content type such as image/video/location.

Syntax: String getContentType()

Return Value: Returns the content type such as image or video or location.

setContentType

This method is used to set the content type such as image,video,location and audio file

Syntax: void setContentType(contentType)

Parameter
Type
Description

contentType

String

Specifies the content type.

ICMediaAttachment


This JS 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.

getMediaId

This method is used to get the mediaId for media attachment.

Syntax: String getMediaId()

Return Value: Returns the mediaId for media attachment.

getSize

This method is used to get the media file size for media attachment.

Syntax:long getSize()

Return Value: Returns the media file size for media attachment.

getURL

This method is used to get the URL for media attachment.

Syntax: String getURL()

Return Value: Returns the URL for media attachment.

setMediaId

This method is used to set mediaId for media attachment.

Syntax: void setMediaId(String id)

Parameter
Type
Description

id

string

Specifies the mediaId for media Attachment

setSize

This method is used to set media file size for media attachment.

Syntax: void setSize( size)

Parameter
Type
Description

size

long

Specifies the media file size for media attachment.

setURL

This method is used to set URL for media attachment.

Syntax: void setURL(url)

Parameter
Type
Description

url

String

Specifies the URL for media attachment.

ICAudioAttachment


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

getDuration

This method is used to get the duration of the applicable audio files.

Syntax: long getDuration()

Return Value: Returns the duration in seconds of the audio files.

setDuration

This method is used to set the duration of the audio files.

Syntax: void setDuration(long duration)

Parameter
Type
Description

duration

long

Specifies the duration in seconds.

ICImageAttachment


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

getPreviewImage

This method is used to get the preview thumbnail as String.

Syntax: String getPreview()

Return Value: Returns the preview thumbnail as String.

setPreview

This method is used to set the preview of the image file.

Syntax: void setPreview(Bitmap preview)

Parameter
Type
Description

preview

String

Specifies the preview of the image file.

ICVideoAttachment


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

getPreviewImage

This method is used to get the video preview thumbnail as String.

Syntax: Bitmap getPreviewImage()

Return Value: Returns the video preview thumbnail as a bitmap.

getDuration

This method is used to get the duration of the applicable video files.

Syntax: long getDuration()

Return Value: Returns the duration in seconds of the video files.

setPreviewImage

This method is used to set the preview of the video file.

Syntax: void setPreviewImage(Bitmap preview)

Parameter
Type
Description

preview

String

Specifies the preview of the video file.

setDuration

This method is used to set the preview of the image file.

Syntax: void setDuration(long duration)

Parameter
Type
Description

duration

long

Specifies the duration in seconds.

ICLocationAttachment


This class exposes data relating to location attachments that are received through RTM or Push, also used to send location to outgoing RTM messages.

getLatitude

This method is used to get the latitude of the location passed in message.

Syntax: double getLatitude()

Return Value: Returns the latitude of the location.

getLongitude

This method is used to get the longitude of the location passed in message.

Syntax: double getLongitude()

Return Value: Returns the longitude of the location.

setLatitude

This method is used to set the latitude of the location passed in message.

Syntax: void setLatitude(double latitude)

Parameter
Type
Description

latitude

double

Specifies the latitude of the location.

setLongitude

This method is used to set the longitude of the location passed in the message.

Syntax: void setLongitude(double longitude)

Parameter
Type
Description

longitude

double

Specifies the longitude of the location.

ICMessageStatus


This Class describes the message status.

Value
Description

None

None is the default message status

Sent

Message sent successfully to connect platform

NotSent

Message sending failed to connect platform

Delivered

Message delivered to the user device

Read

A message read by the user device

ICMessageType


This Class describes the message types.

Value
Description

Message

Standard Push or RTM.

MessageNotification

Represents the notification part of an RTM.

ReadReceipt

Message data is a ReadReceipt, only TransactionId is available and can be used to match the receipt to the original message.

Republish

Message is a republish of a MO, all data from the original message is available.

Alert

Message data is alert from 'Connect' platform.

DeliveryReceipt

Message data is a DeliveryReceipt, TransactionId is available and can be used to match the receipt to the original message.

Message

Standard Push or RTM

MessageNotification

Represents the notification part of an RTM

ReadReceipt

Message data is a ReadReceipt, only TransactionId is available and can be used to match the receipt to the original message.

Republish

A message is a republish of a MO, all data from the original message is available.

TypingStart

Message data is a TypingStart from connect platform end.

TypingStop

Message data is a TypingStop from connect platform end.

ICThread


getId

This method is used to get the thread Id information.

Syntax: String getId()

Return Value: Thread Id information.

getTitle

This method is used to get the thread title.

Syntax: String getTitle()

Return Value: Thread title.

setTitle

This method is used to set the thread title.

Syntax: void setTitle(final String title)

Parameter
Type
Description

title

string

Title of the thread.

getCategory

This method is used to get the category thread.

Syntax: String getCategory()

Return Value: Thread Category.

setCategory

This method is used to set the category thread.

Syntax: void setCategory(String category)

Parameter
Type
Description

category

String

Category of the thread.

getExternalId

This method is used to get the external id of the thread.

Syntax: String getExternalId()

Return Value: Thread External Id.

setExternalId

This method is used to set the external id of the thread.

Syntax: void setExternalId(String externalId)

Parameter
Type
Description

externalId

String

Thread externalID

getType

This method is used to get the thread type.

Syntax: String getType()

Return Value: Returns Thread Type.

setType

This method is used to set the thread type.

Syntax: void setType(String type)

Parameter
Type
Description

type

String

Thread type

getExtras

This method is used to get the extras.

Syntax: JSObject getExtras()

Return Value: Returns Extras.

setExtras

This method is used to set the extras.

Syntax: void setExtras(JSObject extras)

Parameter
Type
Description

Extras

extras

Extras of the thread

getStatus

This method is used to get the status of the thread.

Syntax: public String getStatus()

Return Value: Returns the status of the thread.

setTitle

This method is used to set the thread title.

Syntax: setTitle(String title )

Parameter
Type
Description

title

string

Title of the thread.

getCreatedAt

This method is used to get the thread created date on connect platform.

Syntax: String getCreatedAt()

Return Value: Thread created date onconnect platform.

getUpdatedAt

This method is used to get the thread updated date at Connect platform.

Syntax: String getUpdatedAt()

Return Value: Thread updated date at the Connect platform.

ICTopic


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

getCreatedAt

This method is used to retrieve the date on which a topic is created.

Syntax: Date getCreatedAt()

Return Value: Returns the date on which the topic is created.

getId

This method is used to get topic Id.

Syntax: String getId()

Return Value: Returns the Id for the Topic.

getTitle

This method is used to get the topic title.

Syntax: String getTitle()

Return Value: Returns the topic title.

getGroup

This method is used to get the topic’s group.

Syntax: String getGroup()

Return Value: Returns the topic's group.

isSubscribed

This method is used to verify whether the current user is subscribed to the topic.

Syntax: Boolean isSubscribed()

Return Value: Returns true if the current user is subscribed to the topic.

getName

This method is used to get the topic name.

Syntax: String getName()

Return Value: Returns the topic name.

ICMessageSynchronizationMode


This Class describes the synchronization types.

Value
Description

Full

Synchronization should synchronize all available data

Limited

Synchronization should occur based on

None

Synchronization should be disabled

ICMessageSynchronizationPolicy

This class allows to set mode & limits to message synchronization process.

setMode

This method allows you to set the mode of synchronization.

Syntax: void setMode(ICMessageSynchronizationMode mode)

Parameter
Type
Description

mode

CMessageSynchronizationMode

message synchronization mode.

setLimits

This method allows you to set the maximum number of threads and the maximum number of messages per thread which will be synchronized.

Syntax: void setLimits(int maxThreads, int maxMessagesPerThread)

Parameter
Type
Description

maxThreads

integer

maximum number of threads which will be synchronized.

maxMessagesPerThread

integer

maximum number of messages per thread which will be synchronized

ICLogTarget


This class exposes the enumeration data with a target, on which the logs will be displayed or recorded.

Value
Description

File

Logs will be displayed in the console

Console

Logs will be recorded in a file.

Please refer to the below table for the corresponding methods and their usages.

Method Name
Usage
Params
Response
Existence in platform (Android / iOS)

getSDKVersion()

To retrieve the SDK build version

No

sdk version

Yes/Yes

isStarted

To verify whether the SDK is started or not

No

true/false

Yes/ No

shutdown

To shutdown the SDK and perform cleanup

No

Yes/ Yes

getDeviceProfile

To get the device profile information that is currently
registered with the SDK

No

Yes/ Yes

unregister

To unregisters the current device profile from the IMIconnect
platform

No

Yes/ Yes

removeprofiledata

removes a parameter of the current device profile from the
IMIconnect platform

current device profile

Yes/ Yes

getDeviceId

To initialize the registration flow

No

Yes/ Yes

isRegistered

To check whether the user is currently registered with
IMIconnect

No

true / false

Yes/ Yes

getPolicyPollingInterval

To get the current policy polling interval in
minutes

No

polling intervals

Yes/ Yes

registerSecurityTokenExceptionListener

To register an object to listen for
Security Token related exceptions

No

Yes/ No

unRegisterSecurityTokenExceptionListener

To unregister a previously
registered Security Token related exceptions

No

Yes/ No

setLogOptions

It sets the log options for the logger.

No

Yes/ Yes

startup

To Initialize the logging system

No

Yes/ Yes

register

It registers a given device profile with the IMIconnect platform

No

Yes/ Yes

getCachedFile

To check if a file exists for a URL

File URL

file

Yes/ Yes

uploadFile

To upload a file to connect platform

File URL

Yes/ Yes

isStarted

To verify whether ICMessaging is started or not

No

true/false

Yes/ No

allowJavascriptInWebviews

To enable JavaScript execution

allowWebViews flag

true/false

Yes/ No

setRetentionDuration

It sets the retention duration of the logs

Days flag

Yes/ Yes

getOutputLocation

To get the default output location

No

Default output
location

Yes/ No

downloadFile

to download a file from a URL

file URL

Yes/ Yes

isFileDownloading

To check if the manager is currently downloading a file at
a URL.

File URL

true/false

Yes/ Yes

isFileUploading

To check if the manager is currently uploading a file

File
path

true/false

Yes/ Yes

isMessageStarted

To verify whether ICMessaging is started or not

No

Yes/ No

connect

To establish a connection to receive Real Time Messages from
IMIconnect platform

No

Yes/ Yes

disconnect

To disconnect the connection between the app and IMIconnect
platform

No

Yes/ Yes

getLogPath

To get the log path

No

log path

No/ Yes

Android specific documentation:

Initialize the SDK
The SDK must be initialized before attempting to use any of its features. The SDK initialization should be done from your Application.onCreate method. If your app does not have an Application class you should create one.

public class YOUR_APP_NAME extends IMIconnectApplication {
    @Override
    public void onCreate() {
        super.onCreate();  // Call to super.onCreate() will initialize the IMIconnect SDK , reads the configuration from app manifest
    }
   
    // Password to generate encryption key for secure preferences
    @Override
    protected String getPassword()
    {
        return "YOUR_PASSWORD";
    }
}

Add your application class in AndroidManifest.xml file

<application
   android:name="YOUR_APP_NAME"
   android:allowBackup="true"
   android:label="@string/app_name"
   android:theme="@style/AppTheme">
   <activity
       android:name="YOUR_ACTIVITY_NAME"
       android:label="@string/app_name">
       <intent-filter>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
       
    </activity>

</application>

Notification Customization

NotificationFactory

Class path : ../src/android/NotificationFactory.java

This class enables the generation of a notification from message as received by the SDK. The default class provides a pre-built notification generation, but you can inherit from this class to introduce your own customizations.

The intended process is for you is to inherit from this class and override onBuildNotification and getActionIconId in order to introduce customizations to the SDK generated notifications.
It is possible to completely replace the internal notification generation by overriding createNotification, in this instance developers would not call the base implementation and would not get any of the pre-build interactive message functionality, nor would getActionIconId or onBuildNotification get called.

Public Methods

Notification

createNotification(Context context, ICMessage message, int notificationId, Bitmap bigPicture)

Int

getActionId(String action, String identifier, ICMessage message)

void

onBuildNotification(Context context, Builder builder, ICMessage message, int notificationId)

For more information about the methods please refer this link (https://docs.imiconnect.com/docs/messaging-1#section-icnotificationfactory)

MessagingReceiver

This class allows the interception of incoming messages and RTM connection status changes, and provides a hook into the notification generation process. The default class provides standard message handling for both basic and interactive message types through notifications. You may inherit from this class to replace or supplement the default functionality. In either case, the receiver must be declared within the Android manifest.

App manifest Copy
A sample app manifest entry. If you inherit a class from MessagingReceiver, replace the name with your class name.

<receiver
      android:name="YOUR_MESSAGE_RECEIVER_NAME"
      android:enabled="true"
      android:exported="true"
      android:permission="com.google.android.c2dm.permission.SEND">
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
          <action android:name="com.imimobile.connect.core.rtmevent"/>
          <action android:name="com.imimobile.connect.core.notification.click"/>
          <action android:name="com.imimobile.connect.core.intent.notification.RECEIVE"/>
      </intent-filter>
  </receiver>

Public Methods

Void

getNotificationFactory()

Void

onConnectionStatusChanged(Context context, ICConnectionStatus status, ICException exception)

Void

onMessageReceived(Context context, ICMessage message)

getNotificationFactory

This method is invoked whenever the SDK needs to generate a local notification. Override this method to provide a custom NotificationFactory in order to customise notifications generated by the SDK. It is recommended that you do not return a new instance every time this method is invoked, instead cache your custom instance and return that.

Syntax: void getNotificationFactory()

Return Value: The default implementation returns the standard NotificationFactory instance.

Cordova Plugin


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.