Cordova Plugin
- Cordova Installation
- Android Installation for Cordova
- Android Local Setup
- iOS Installing Requirements
- iOS Installation for Cordova
- iOS Local Setup
- Notification Customization
Cordova Installation
- To setup the Cordova plugin in your machine, you are required to install npm and Node in your machine.
- Once you have npm installed, install the Cordova in your machine using the following command.
$ npm install -g cordova
- 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.
- 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. - 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 - 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
- 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"/>
- Open build.gradle file and add the below tags inside the buildScript -> dependencies
- Get the google-services.json file from firebase and copy the same in platforms -> androidlocation.
- 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
-
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.
-
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
- To add custom plug-in to the application; navigate to the cordova application folder(myApp) and executive the following command.
in the example above, IMIconnectPlugin is the plug-in** name.$ cordova plugin add IMIconnectPlugin
- 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](https://docs.imiconnect.com/docs/ios-sdk-quickstart-guide-v1#section-setup-apns) 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](https://docs.imiconnect.com/docs/ios-sdk-quickstart-guide-v1#section-rich-notification-support) 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](https://docs.imiconnect.com/docs/ios-sdk-quickstart-guide-v1#section-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
```
[block:callout]
{
"type": "info",
"title": "NOTE",
"body": "Add other dependent frameworks files."
}
[/block]
2. 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``.
[block:image]
{
"images": [
{
"image": [
"https://files.readme.io/37013d7-Cordova_App_config_Setup.png",
"Cordova_App config Setup.png",
708,
87,
"#e2eaf4"
],
"caption": "Applicaiton level plist",
"border": true
}
]
}
[/block]
2. Start the SDK in your AppDelegate class by using the sample code below.
[block:callout]
{
"type": "info",
"title": "NOTE",
"body": "Import IMIconnectPlugin in AppDelegate.m file by including: #import \"IMIconnectPlugin.h\""
}
[/block]
[block:code]
{
"codes": [
{
"code": "- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions\n{\n self.viewController = [[MainViewController alloc] init];\n\n //Password to generate encryption key for secure preferences\n IMIconnectPlugin *pushHandler = [self.viewController getCommandInstance:@\"IMIconnectPlugin\"];\n pushHandler.password = @\"setYourPassword\";\n \n //SDK initializing\n NSDictionary *infoPlistDict = [[NSBundle mainBundle] infoDictionary];\n NSDictionary *RootDict = infoPlistDict[@\"Root\"];\n NSString *clientkey = RootDict[@\"clientKey\"];\n NSString *appId = RootDict[@\"appId\"];\n ICConfig *icConfig = [[ICConfig alloc] initWithClientKey:clientkey forAppId:appId];\n \n NSError *error;\n [IMIconnect startupWithConfig:icConfig error:&error];\n\n \n return [super application:application didFinishLaunchingWithOptions:launchOptions];\n}\n",
"language": "objectivec"
}
]
}
[/block]
##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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.startup(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###startupWithConfig
Initializes the SDK by using the config params appId, clientKey values that required to be defined by the developer.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "appId",
"1-0": "clientKey",
"0-2": "The app id that is generated while creating an app asset within IMIconnect.",
"1-2": "The client key that is generated while creating an app asset within IMIconnect.",
"0-1": "String",
"1-1": "String"
},
"cols": 3,
"rows": 2
}
[/block]
**NOTE**: And this method is called by the plugin when the application is launched. So no need to call this method explicitly.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.startupWithConfig(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }, \n\t\t\t appId, clientKey ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###startupLogger
This method is used to Initialize the logging system.
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.startupLogger(\n function(result){\n console.log(result);\n }); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getSDKVersion:
This method retrieves the SDK build version. Use the below method to call the ``getSDKVersion``
[block:code]
{
"codes": [
{
"code": "\nIMIconnectPlugin.getSDKVersion()(\n function(result){\n console.log(result);\n }\n );\n\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.isStarted(\n function(result){\n console.log(result);\n }\n );",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.shutdown(\n\tfunction (result) {\n\t\tconsole.log(result);\n\t}\n);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###register
Registers the provided device profile with the IMIconnect platform.
[block:parameters]
{
"data": {
"h-0": "Parameters",
"h-2": "Description",
"h-1": "Type",
"0-0": "deviceProfile",
"0-1": "ICDeviceProfile",
"0-2": "The device profile to register"
},
"cols": 3,
"rows": 1
}
[/block]
Invoked on registration success or failure
[block:code]
{
"codes": [
{
"code": "var deviceProfile = new ICDeviceProfile();\n deviceProfile.setAppUserId(\"9999\");\n\t\t\tdeviceProfile.setDeviceId(\"PROVIDE UNIQUE DEVICE ID\"); \n IMIconnectPlugin.register(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }, \n deviceProfile ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
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
[block:code]
{
"codes": [
{
"code": "var deviceProfile = new ICDeviceProfile();\ndeviceProfile.setAppUserId(\"9999\");\ndeviceProfile.setDeviceId(\"PROVIDE UNIQUE DEVICE ID\");\ndeviceProfile.setGuest(true);\nIMIconnectPlugin.register(\n function(jsonObj) {\n console.log(\"Registration Succeeded : \" + JSON.stringify(jsonObj));\n },\n function(errJsonObj) {\n console.log(JSON.stringify(errJsonObj));\n }, deviceProfile);",
"language": "javascript",
"name": "CODE"
}
]
}
[/block]
###getDeviceProfile
This method returns the device profile information that is currently registered with the SDK. Returns null if no device is currently registered.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getDeviceProfile (\n function(result){\n console.log(result);\n }\n);",
"language": "text",
"name": "code"
}
]
}
[/block]
###unregister
This method unregisters the current device profile from the IMIconnect platform. Use the below script to call the unregister method.
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.unregister(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }\n);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###updateProfileData :
Updates a parameter of the current device profile within the IMIconnect platform.
[block:parameters]
{
"data": {
"h-0": "Parameters",
"h-1": "Type",
"h-2": "Description",
"0-0": "param",
"0-1": "ICDeviceProfileParam",
"0-2": "An ICDeviceProfileParam indicating the parameter which should be updated.",
"1-0": "value",
"1-1": "String",
"1-2": "A String containing the data value."
},
"cols": 3,
"rows": 2
}
[/block]
[block:code]
{
"codes": [
{
"code": "Update userId:\n\n IMIconnectPlugin.updateProfileData(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n },\n\t\t\t\t\tICDeviceProfileParam.UserId, \"9999\"\n );\n\nUpdate customerId:\n\n IMIconnectPlugin.updateProfileData(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n },\n\t\t\t\t\tICDeviceProfileParam.CustomerId, \"6666\"\n );\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###removeProfileData
Removes a parameter of the current device profile from the IMIconnect platform.
[block:parameters]
{
"data": {
"h-0": "Parameters",
"h-1": "Type",
"h-2": "Description",
"0-0": "param",
"0-1": "ICDeviceProfileParam",
"0-2": "The ICDeviceProfileParam representing the parameter data which should be removed."
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "Remove userId:\n\n IMIconnectPlugin.removeProfileData(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n },\n\t\t\t\t\t ICDeviceProfileParam.UserId\n );\n\t\t\t \nRemove customerId :\n\n IMIconnectPlugin.removeProfileData(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n },\n\t\t\t\t\t ICDeviceProfileParam.CustomerId\n );\t\t\t ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getDeviceId
This method returns the ``deviceId`` passed during registration. Use the below method to call the getDeviceId.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getDeviceId(\n function(result){\n console.log(result);\n }\n );",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###isRegistered
This method is used to check whether the user is currently registered with IMIconnect. Use the below method to call the isRegistered.
Returns: Retuns``true`` if the device is registered, otherwise ``false``.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.isRegistered(\n function(result){\n console.log(result);\n }\n );",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "intervalMinutes",
"0-1": "Integer",
"0-2": "Specifies how the SDK will poll for policy updates."
},
"cols": 3,
"rows": 1
}
[/block]
The default value is 30 minutes.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setPolicyPollingInterval(\n function(result){\n console.log(result);\n }, intervalMinutes );\t\n \n ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getPolicyPollingInterval
This method returns the current policy polling interval in minutes.
Returns: The policy polling interval in minutes.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getPolicyPollingInterval(\n function(result){\n console.log(result);\n }\n);",
"language": "text",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setSecurityToken(function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }, token);\n\t\t\t\t\t\t\t",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.registerSecurityTokenExceptionListener(\n function(error){\n console.log(error);\n }\n );",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.unRegisterSecurityTokenExceptionListener(\n function(error){\n console.log(error);\n }\n);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###setLogOptions:
This method sets the log options for the logger. Use the below method to call the setLogOptions.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-2": "Description",
"h-1": "Type",
"0-0": "logType",
"0-1": "ICLogType",
"0-2": "The type of logs that will be logged.",
"1-0": "logTarget",
"1-1": "ICLogTarget",
"1-2": "The target on which the logs will be displayed/recorded."
},
"cols": 3,
"rows": 2
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setLogOptions(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n },\n\t\t\t\t\tICLogType.Debug, ICLogTarget.Console ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-2": "Description",
"h-1": "Type",
"0-0": "days",
"0-1": "Integer",
"0-2": "Number of days after which the logs will be purged."
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setRetentionDuration(\n function(result){\n console.log(result);\n },\n\t\t\t\t\tretentionDuration // provide no of days retentionDuration\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getOutputLocation
This method returns the default output location. Use the below method to call the ``getOutputLocation``.
Return value: Returns absolute directory.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getOutputLocation(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###allowJavascriptInWebviews
This method allows JavaScript execution within WebView instances that are created by the SDK. The default value is false.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-2": "Description",
"h-1": "Type",
"0-0": "flag",
"0-1": "Boolean",
"0-2": "True if WebView Javascript execution is allowed."
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.allowJavascriptInWebviews(\n function(result){\n console.log(result);\n }, \n true\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.isMessageStarted(\n function(result){\n console.log(result);\n }\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.connect(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.disconnect(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###fetchTopics
To get a list of topics that are configured with IMIconnect, you need to send the offset using the following javascript code
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-2": "Passes an offset value to fetch topics from that offset value.",
"0-0": "offset",
"0-1": "Integer"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "var offset = 0;\nIMIconnectPlugin.fetchTopics(function(topics, hasMoreData) {\n var log = \"[\";\n for (var i = 0; i < topics.length; i++) {\n log += topics[i].getName() + \", \";\n }\n log += \"]\";\n console.log(\"Topics: \" + log + \", hasMoreData: \" + hasMoreData);\n}, function(errJsonObj) {\n console.log(\"Error : \" + JSON.stringify(errJsonObj));\n}, offset);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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
[block:code]
{
"codes": [
{
"code": " IMIconnectPlugin.subscribeTopic(\n\t\t\t\t\t\tfunction (result) { \n\t\t\t\t\t\t\tconsole.log(result); \n\t\t\t\t\t\t},\n\t\t\t\t\t\tfunction (error) { \n\t\t\t\t\t\tconsole.log(error);\n\t\t\t\t\t\t}, \n\t\t\t\t\t\ttopicId);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.unsubscribeTopic(\n\t\t\t\tfunction (result) { \n\t\t\t\t\tconsole.log(result); \n\t\t\t\t}, \n\t\t\t\tfunction (error) { \n\t\t\t\t\tconsole.log(error); \n\t\t\t\t},\n\t\t\t\ttopicId);\n",
"language": "javascript"
}
]
}
[/block]
###connectionStatusChangedListener
This listener is used for activating the connection status change listener between SDK and IMIconnect platform.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.connectionStatusChangedListener(\n\t\t\t\t\t function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n });",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getConnectionStatus(\n\t\t\t\tfunction(result){\n console.log(result);\n });",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###createThread
This method creates a Thread with thread object param for users using the following javascript code.
[block:code]
{
"codes": [
{
"code": " var thread = new ICThread();\n thread.setTitle(\"MyTitle\");\n thread.setCategory(\"MyCategory\");\n IMIconnectPlugin.createThread(function (thread) {\n window.alert(thread.getTitle());}, function (error) { console.log(error); }, thread);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
[block:callout]
{
"type": "info",
"title": "Note"
}
[/block]
###updateThread:
This method is used to update a thread.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "thread",
"0-2": "Update the passed Thread(Instance of ICThread).",
"0-1": "ICThread"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.updateThread(function (thread) {\n window.alert(thread.getTitle());}, function (error) { console.log(error); }, thread);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###closeThread
This method is used to close the thread.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "thread",
"0-2": "Close the passed Thread(Instance of ICThread).",
"0-1": "ICThread"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.closeThread(function (thread) {\n window.alert(thread.getTitle());}, function (error) { console.log(error); }, thread);\n \n",
"language": "javascript"
}
]
}
[/block]
###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.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "beforeDate",
"0-2": "Pass value to fetch Threads before that Date",
"1-0": "limit",
"1-2": "Pass value to limit the fetching thread count",
"0-1": "Date",
"1-1": "Integer"
},
"cols": 3,
"rows": 2
}
[/block]
[block:code]
{
"codes": [
{
"code": "var beforeDate = new Date();\nvar limit = 30;\nIMIconnectPlugin.fetchThreads(function(threads, hasMoreData) {\n var log = \"[\";\n for (var i = 0; i < threads.length; i++) {\n log += threads[i].getTitle() + \", \";\n }\n log += \"]\";\n console.log(\"Threads: \" + log + \", hasMoreData: \" + hasMoreData);\n}, function(errJsonObj) {\n console.log(\"Error: \" + JSON.stringify(errJsonObj));\n}, beforeDate, limit);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.fetchTopics(function (topics) {\n var text = \"\";\n for (var i = 0; i < topics.length; i++) {\n text += topics[i].getName() + \"<br>\";\n }\n window.alert(text)\n \n }, function (error) { console.log(error); },{ \"offset\": 0 });\t",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###publishMessage
This method is used to publish the passed ``ICMessage`` instance through RTM connection.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "message",
"0-2": "Refer to ICMessage JS class.",
"0-1": "ICMessage"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "var message = new ICMessage();\n message.setMessage(\"Test Message\");\n\t\tmessage.setThread(thread);\nIMIconnectPlugin.publishMessage(function (icMessage) {\n console.log(JSON.stringify(icMessage.toJSON()));\n }, function (error) { console.log(error); }, message);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###setMessageSyncPolicy
This method allows you to set the policy object which describes the extent of data to be synchronized.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "policy",
"0-2": "Message synchronization policy object. refer ICMessageSynchronizationPolicy JS class.",
"0-1": "ICMessageSynchronizationPolicy"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "var syncPolicy = new ICMessageSynchronizationPolicy();\n syncPolicy.setMode(ICMessageSynchronizationMode.Limited);\n syncPolicy.setLimits(10,20); // maxThreads - 10, maxMessagesPerThread - 20\n IMIconnectPlugin.setMessageSyncPolicy(\n\t\t\t\t\t\t\t\t\tfunction (result) \n\t\t\t\t\t\t\t\t\t{ window.alert(result); },\n\t\t\t\t\t\t\t\t\tsyncPolicy);\t\t",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###MessageListener
Interface for listening to incoming messages
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.messageListener(\n\n function(messages) {\n\n \n\n var text = \"\";\n\n for (var i = 0; i < messages.length; i++) {\n\n text += messages[i].getMessage() + \"<br>\";\n\n }\n\n console.log(text);\n \n\n });",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###DeepLinkListener
Interface for listening deep link actions
[block:code]
{
"codes": [
{
"code": "\n IMIconnectPlugin.deeplinkListener(function(resultJson) {\n\n console.log('deeplinkListener : ' + JSON.stringify(resultJson));\n\n\n \n\n });",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###fetchMessages:
This method is used to get a list of messages from the Connect platform.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "beforeDate",
"0-2": "Specifies the date before the messages needs to returned.",
"1-0": "limit",
"2-0": "threadId",
"1-2": "Pass value to limit the fetching message count.",
"2-2": "Specifies the value of ThreadId.",
"0-1": "Date",
"1-1": "Integer",
"2-1": "string"
},
"cols": 3,
"rows": 3
}
[/block]
[block:code]
{
"codes": [
{
"code": "var threadId = \"Thread ID\";\nvar beforeDate = new Date();\nvar limit = 30;\nIMIconnectPlugin.fetchMessages(function(messages, hasMoreData) {\n var log = \"[\";\n for (var i = 0; i < messages.length; i++) {\n log += messages[i].getMessage() + \", \";\n }\n log += \"]\";\n console.log(\"messages: \" + log + \", hasMoreData: \" + hasMoreData);\n}, function(errJsonObj) {\n console.log(\"Error: \" + JSON.stringify(errJsonObj));\n}, beforeDate, limit, threadId);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###setMessageAsRead
This method is used to update the status of the message identified by transactionId as Read.
[block:parameters]
{
"data": {
"h-0": "Paramter",
"h-1": "Type",
"h-2": "Description",
"0-0": "transactionId",
"0-2": "Specifies a single transaction id.",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setMessageAsRead(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }, \n transactionId\n ); ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###setMessagesAsRead
To set multiple messages as read pass array of transactionIds separated by comma (,)
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "transactionIds",
"0-1": "String",
"0-2": "Specifies an array of transaction ids."
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.setMessagesAsRead(\n function(result){\n console.log(result);\n },\n function(error){\n console.log(error);\n }, \n transactionIds\n ); \n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###uploadFile
This method is used to upload a file to IMIconnect platform.
[block:parameters]
{
"data": {
"0-0": "filePath",
"0-2": "local file path to be uploaded",
"h-0": "Paramters",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.uploadFile(\n\t\t\t\t\t\tfunction (resultJSObject) { console.log(resultJSObject); },\n\t\t\t\t\t\tfunction (error) { console.log(error); },\n\t\t\t\t\t\tfilePath);\t",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###isFileUploading
This method is used to check if the manager is currently uploading a file
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "filePath",
"0-2": "The local file to be checked.",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: True if the file is currently being uploaded.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.isFileUploading(\n\t\t\t\t\t\t\tfunction (status) { console.log(status); },\n\t\t\t\t\t\t\tfilePath);\t",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###downloadFile
This method is used to download a file from URL.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Descripition",
"0-0": "fileUrl",
"0-2": "The URL of the file to be downloaded.",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.downloadFile(\n\t\t\t\t\t\t\tfunction (resultJSObject) { console.log(resultJSObject); },\n\t\t\t\t\t\t\tfunction (error) { console.log(error); },\n\t\t\t\t\t\t\tfileUrl);\n \n ",
"language": "text",
"name": "Code"
}
]
}
[/block]
###isFileDownloading:
This method is used to check if the manager is currently downloading a file at a URL.
[block:parameters]
{
"data": {
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-0": "fileUrl",
"0-2": "The URL of the file that will be checked.",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.isFileDownloading(\n\t\t\t\t\t\t\t\tfunction (status) { console.log(status); }, \n\t\t\t\t\t\t\t\tfileUrl);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getCachedFile
This method is used to check if a file exists for a URL.
[block:parameters]
{
"data": {
"0-0": "fileUrl",
"0-2": "The URL of the file that will be checked.",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getCachedFile(\n\t\t\t\t\t\t\t\tfunction (filePath) { console.log(filePath); }, \n\t\t\t\t\t\t\t\tfunction (error) { console.log(error); },\n\t\t\t\t\t\t\t\tfileUrl);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###saveMessage
This method saves single [ICMessage](#section-icmessage)
[block:parameters]
{
"data": {
"0-0": "message",
"0-2": "The [ICMessage](#section-icmessage) to be saved",
"h-0": "Parameter",
"h-1": "Type",
"0-1": "ICMessage",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns true if message storage completes, false Otherwise
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.saveMessage(function (status) { console.log(status); }, function (error) { console.log(error); }, message);\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###saveMessages
This method saves multiple [ICMessages](#section-icmessage)
[block:parameters]
{
"data": {
"0-0": "messages",
"0-2": "The array of [ICMessages](#section-icmessage) to be saved",
"h-0": "Parameter",
"h-1": "type",
"h-2": "Description",
"0-1": "ICMessage[]"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns true if message storage completes, false Otherwise
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.saveMessages(function (status) { console.log(status); }, function (error) { console.log(error); }, messages);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###loadMessage
This method loads single [ICMessage](#section-icmessage) from local storage based on transactionId.
[block:parameters]
{
"data": {
"0-0": "transactionId",
"0-2": "The transactionId to retrieve from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns [ICMessage](#section-icmessage) instance if message exists with transactionId
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.loadMessage(function (message) {\n console.log(message.getMessage()); \n }, function (error) { console.log(error); }, transactionId);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###loadMessages
This method Loads [ICMessages](#section-icmessage) from local storage based on threadId and submitted date with a specific limit
[block:parameters]
{
"data": {
"0-0": "threadId",
"0-2": "The threadId to be retrieved from local storage",
"1-0": "submittedBefore",
"2-0": "submittedAfter",
"4-0": "limit - The limit to be used to fetch limited number of messages from local storage",
"3-0": "limit",
"3-2": "The limit to be used to fetch limited number of messages from local storage",
"2-2": "The submittedAfter to be used to fetch messages after submittedAfter from local storage",
"1-2": "The submittedBefore to be used to fetch messages before submittedBefore from local storage",
"0-1": "String",
"1-1": "Date",
"2-1": "Date",
"3-1": "Integer",
"h-0": "Parameter"
},
"cols": 3,
"rows": 4
}
[/block]
Return Value: Returns array of [ICMessage](#section-icmessage) instance if message exists with threadId.
[block:code]
{
"codes": [
{
"code": "MIconnectPlugin.loadMessages(function (messages) {\n var text = \"\";\n for (var i = 0; i < messages.length; i++) {\n text += messages[i].getMessage() + \"<br>\";\n }\n\t\t\t\t\t\t\t console.log(text); \n }, function (error) { console.log(error); },threadId, submittedBefore,submittedAfter, 30);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###deleteMessageFromStore
This method allows you to delete single [ICMessages](#section-icmessage) from local storage based on transactionId
[block:parameters]
{
"data": {
"0-0": "transactionId",
"0-2": "The transactionId to be deleted from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns ``true`` if delete completes, ``false`` Otherwise.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.deleteMessageFromStore(function (status) {\n console.log(status);\n }, function (error) { console.log(error); }, transactionId);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getMessageCount
This method provides the count of messages from local storage based on threadId.
[block:parameters]
{
"data": {
"0-0": "threadId",
"0-2": "The threadId to be fetched count from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns count of messages.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getMessageCount(function (count) {\n console.log(count);\n }, function (error) { console.log(error);\n \n },threadId);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###saveThread
This method saves single [ICThread](#section-icthread)
[block:parameters]
{
"data": {
"0-0": "thread",
"0-2": "The [ICThread](#section-icthread) to be saved",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "ICThread"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Return ``true`` if thread storage completes, ``false`` Otherwise.
[block:code]
{
"codes": [
{
"code": "var thread = new ICThread();\n thread.setTitle(threadName);\n IMIconnectPlugin.saveThread(function (status) {\n console.log(status);\n },function (error) { console.log(error); }, thread);\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###saveThreads
This method saves multiple [ICThreads](#section-icthread)
[block:parameters]
{
"data": {
"0-0": "threads",
"0-2": "The array of [ICThreads](#section-icthread) to be saved",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "ICThread[]"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Return true if thread storage completes, false Otherwise.
[block:code]
{
"codes": [
{
"code": "var threads = [];\n var thread = new ICThread();\n thread.setTitle(threadName);\n\t\tthreads.push(thread);\n\t\tIMIconnectPlugin.saveThreads(function (status) {\n console.log(status);\n }, function (error) { console.log(error); }, \n threads);\n ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###loadThread
This method loads single [ICThread](#section-icthread) from local storage based on threadId
[block:parameters]
{
"data": {
"0-0": "threadId",
"0-2": "The threadId to be retrieved from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns [ICThread](#section-icthread) instance if thread exists with threadId.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.loadThread(function (thread) {\n console.log(thread.getTitle())\n }, function (error) { console.log(error); }, threadId);\n\n\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###loadThreads
This method Loads [ICThreads](#section-icthread) from local storage based date modifiedBefore with specific limit
[block:parameters]
{
"data": {
"0-0": "modifiedBefore",
"1-0": "modifiedAfter",
"2-0": "limit",
"2-2": "The limit to be used to fetch limited number of threads from local storage",
"1-2": "The modifiedAfter(Date instance) to be used to fetch threads modified after from local storage",
"0-2": "The modifiedBefore(Date instance) to be used to fetch threads modified before from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "Date",
"1-1": "Date",
"2-1": "Integer"
},
"cols": 3,
"rows": 3
}
[/block]
Return Value: Returns array of [ICThreads](#section-icthread) instance, if threads exists between before & after the modified date with limit.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.loadThreads(function (threads) {\n \n var text = \"\";\n for (var i = 0; i < threads.length; i++) {\n text += threads[i].getTitle() + \"<br>\"; \n }\n console.log(text);\n }, function (error) { console.log(error); }, modifiedBefore, modifiedAfter,30);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###loadUnreadThreads
This method loads unread [ICThreads](#section-icthread) from local storage with specific limit.
[block:parameters]
{
"data": {
"0-0": "limit",
"0-2": "The limit to be used to fetch limited number of unread threads from local storage",
"h-0": "Paramter",
"h-1": "Type",
"h-2": "Description",
"0-1": "Integer"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns array of Unread [ICThreads](#section-icthread) instance with limit.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.loadUnreadThreads(function (threads) {\n var text = \"\";\n for (var i = 0; i < threads.length; i++) {\n text += threads[i].getTitle() + \"<br>\";\n }\n\t\t\t\t\t\t\t\t\tconsole.log(text);\n }, function (error) { console.log(error); }, 30);",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###deleteThread
This method deletes single [ICThread](#section-icthread) from local storage based on threadId
[block:parameters]
{
"data": {
"0-0": "threadId",
"0-2": "The threadId to be deleted from local storage",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description",
"0-1": "String"
},
"cols": 3,
"rows": 1
}
[/block]
Return Value: Returns ``true`` if delete completes, ``false`` Otherwise.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.deleteThread(function (status) {\n console.log(status);\n }, function (error) { console.log(error); }, \n threadId);\n \n ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getThreadCount
This method gives total number of threads count from local storage.
Return Value : Returns count of threads
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getThreadCount(function (count) {\n console.log(count);\n }, function (error) { console.log(error); });",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getUnReadThreadCount
This method gives count of unRead messages threads count.
Return Value: Returns count of unRead messages threads count.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getUnReadThreadCount(function (count) {\n console.log(count);\n }, function (error) { console.log(error); });\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###deleteAll
This method deletes complete threads & messages.
Return Value: Returns ``true`` if delete completes, ``false`` Otherwise
[block:code]
{
"codes": [
{
"code": "MIconnectPlugin.deleteAll(function (status) {\n console.log(count);\n }, function (error) { console.log(error); });\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###publishEvent
Invoke publishEvent to publish your custom events info to the IMIconnect platform.
[block:code]
{
"codes": [
{
"code": "var eventJsonObj = JSON.parse(\"{\\\"name\\\":\\\"John\\\",\\\"age\\\":30,\\\"city\\\":\\\"New\nYork\\\"}\");\nIMIconnectPlugin.publishEvent(function(jsonObj) {\n console.log(\"Successful: \" + JSON.stringify(jsonObj));\n },\n function(errJsonObj) {\n console.log(\"Failed: \" + JSON.stringify(errJsonObj));\n }, eventJsonObj);\n",
"language": "javascript",
"name": "CODE"
}
]
}
[/block]
###publishTypingIndicator
Facilitates publication of typing start/stop indicator events to the IMIconnect platform.
[block:code]
{
"codes": [
{
"code": " var threadId = \"Your thread id\";\n var isIndicatorEnabled = true;\n IMIconnectPlugin.publishTypingIndicator(function(status) {\n console.log(\"Successfully published typing indicator: \" + status);\n },\n function(errJsonObj) {\n console.log(\"Error: \" + JSON.stringify(errJsonObj));\n }, threadId, isIndicatorEnabled);",
"language": "javascript",
"name": "CODE"
}
]
}
[/block]
###deleteMessage
Invoke deleteMessage to delete the given message transaction id from the IMIconnect platform.
[block:code]
{
"codes": [
{
"code": "var messageTransactionId = \"Your message's transaction id\";\nIMIconnectPlugin.deleteMessage(function(id) {\n console.log(\"Deleted successfully: \" + id);\n },\n function(errJsonObj) {\n console.log(\"Error: \" + JSON.stringify(errJsonObj));\n }, messageTransactionId);",
"language": "javascript",
"name": "CODE"
}
]
}
[/block]
##ICDeviceProfile
###getAppUserId
This method is used to get the App user ID. Use the below script to call the getAppUserId method.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getDeviceProfile (\n function(deviceProfile){\t\t\t\t\t\n console.log(deviceProfile.getAppUserId();\n }\n);\n ",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###getCustomerId
This method is used to get the Customer ID. Use the below script to call the getCustomerId method.
[block:code]
{
"codes": [
{
"code": "\t\tIMIconnectPlugin.getDeviceProfile (\n function(deviceProfile){\t\t\t\t\t\n console.log(deviceProfile.getCustomerId();\n }\n );",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###isAppUserSystemGenerated
This method is used to validate if userId is generated by IMIconnect system or not.
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getDeviceProfile (\n function(deviceProfile){\t\t\t\t\t\n console.log(deviceProfile.isAppUserSystemGenerated();\n }\n );\n",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
###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).
[block:code]
{
"codes": [
{
"code": "IMIconnectPlugin.getDefaultDeviceId(function(defaultDeviceId) {\n console.log('DefaultDeviceId : ' + defaultDeviceId);\n});",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "tags",
"0-1": "JSObject",
"0-2": "Specifies the JSObject.",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "message",
"0-2": "Specifies the content of the text message.",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "attachments",
"0-2": "Refer to ICAttachment class.",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###setThread
This method is used to set the thread details that need to be specified in the message.
Syntax: ``void setThread(final ICThread thread)``
[block:parameters]
{
"data": {
"0-0": "Thread",
"0-2": "Refer to [ICThread](#section-icthread) class.",
"0-1": "ICThread",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "status",
"0-2": "set message status",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "contentType",
"0-1": "String",
"0-2": "Specifies the content type.",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "id",
"0-2": "Specifies the mediaId for media Attachment",
"0-1": "string",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###setSize
This method is used to set media file size for media attachment.
Syntax: ``void setSize( size)``
[block:parameters]
{
"data": {
"0-0": "size",
"0-2": "Specifies the media file size for media attachment.",
"0-1": "long",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###setURL
This method is used to set URL for media attachment.
Syntax: ``void setURL(url)``
[block:parameters]
{
"data": {
"0-0": "url",
"0-2": "Specifies the URL for media attachment.",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "duration",
"0-2": "Specifies the duration in seconds.",
"0-1": "long",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "preview",
"0-2": "Specifies the preview of the image file.",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "preview",
"0-2": "Specifies the preview of the video file.",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###setDuration
This method is used to set the preview of the image file.
Syntax: ``void setDuration(long duration)``
[block:parameters]
{
"data": {
"0-0": "duration",
"0-2": "Specifies the duration in seconds.",
"0-1": "long",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "latitude",
"0-2": "Specifies the latitude of the location.",
"0-1": "double",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###setLongitude
This method is used to set the longitude of the location passed in the message.
Syntax: ``void setLongitude(double longitude)``
[block:parameters]
{
"data": {
"0-0": "longitude",
"0-2": "Specifies the longitude of the location.",
"0-1": "double",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
##ICMessageStatus
***
This Class describes the message status.
[block:parameters]
{
"data": {
"h-0": "Value",
"h-1": "Description",
"0-0": "None",
"1-0": "Sent",
"2-0": "NotSent",
"3-0": "Delivered",
"4-0": "Read",
"4-1": "A message read by the user device",
"3-1": "Message delivered to the user device",
"2-1": "Message sending failed to connect platform",
"1-1": "Message sent successfully to connect platform",
"0-1": "None is the default message status"
},
"cols": 2,
"rows": 5
}
[/block]
##ICMessageType
***
This Class describes the message types.
[block:parameters]
{
"data": {
"h-0": "Value",
"h-1": "Description",
"0-0": "Message",
"0-1": "Standard Push or RTM.",
"1-0": "MessageNotification",
"1-1": "Represents the notification part of an RTM.",
"2-0": "ReadReceipt",
"2-1": "Message data is a ReadReceipt, only TransactionId is available and can be used to match the receipt to the original message.",
"3-0": "Republish",
"3-1": "Message is a republish of a MO, all data from the original message is available.",
"4-0": "Alert",
"4-1": "Message data is alert from 'Connect' platform.",
"5-0": "DeliveryReceipt",
"5-1": "Message data is a DeliveryReceipt, TransactionId is available and can be used to match the receipt to the original message.",
"6-0": "Message",
"6-1": "Standard Push or RTM",
"7-1": "Represents the notification part of an RTM",
"7-0": "MessageNotification",
"8-0": "ReadReceipt",
"8-1": "Message data is a ReadReceipt, only TransactionId is available and can be used to match the receipt to the original message.",
"9-0": "Republish",
"9-1": "A message is a republish of a MO, all data from the original message is available.",
"10-0": "TypingStart",
"10-1": "Message data is a TypingStart from connect platform end.",
"11-0": "TypingStop",
"11-1": "Message data is a TypingStop from connect platform end."
},
"cols": 2,
"rows": 12
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-0": "title",
"0-2": "Title of the thread.",
"0-1": "string",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "category",
"0-2": "Category of the thread.",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "externalId",
"0-2": "Thread externalID",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "type",
"0-2": "Thread type",
"0-1": "String",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "Extras",
"0-2": "Extras of the thread",
"0-1": "extras",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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 )``
[block:parameters]
{
"data": {
"0-0": "title",
"0-2": "Title of the thread.",
"0-1": "string",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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.
[block:parameters]
{
"data": {
"h-0": "Value",
"h-1": "Description",
"0-0": "Full",
"1-0": "Limited",
"2-0": "None",
"0-1": "Synchronization should synchronize all available data",
"1-1": "Synchronization should occur based on",
"2-1": "Synchronization should be disabled"
},
"cols": 2,
"rows": 3
}
[/block]
##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)``
[block:parameters]
{
"data": {
"0-1": "CMessageSynchronizationMode",
"0-0": "mode",
"0-2": "message synchronization mode.",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 1
}
[/block]
###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)``
[block:parameters]
{
"data": {
"0-0": "maxThreads",
"0-1": "integer",
"1-1": "integer",
"0-2": "maximum number of threads which will be synchronized.",
"1-0": "maxMessagesPerThread",
"1-2": "maximum number of messages per thread which will be synchronized",
"h-0": "Parameter",
"h-1": "Type",
"h-2": "Description"
},
"cols": 3,
"rows": 2
}
[/block]
##ICLogTarget
***
This class exposes the enumeration data with a target, on which the logs will be displayed or recorded.
[block:parameters]
{
"data": {
"h-0": "Value",
"h-1": "Description",
"0-0": "File",
"0-1": "Logs will be displayed in the console",
"1-0": "Console",
"1-1": "Logs will be recorded in a file."
},
"cols": 2,
"rows": 2
}
[/block]
Please refer to the below table for the corresponding methods and their usages.
[block:parameters]
{
"data": {
"h-0": "Method Name",
"h-1": "Usage",
"h-2": "Params",
"h-3": "Response",
"h-4": "Existence in platform (Android / iOS)",
"0-0": "getSDKVersion()",
"0-1": "To retrieve the SDK build version",
"0-2": "No",
"0-3": "sdk version",
"0-4": "Yes/Yes",
"1-0": "isStarted",
"1-1": "To verify whether the SDK is started or not",
"1-2": "No",
"1-3": "true/false",
"1-4": "Yes/ No",
"2-0": "shutdown",
"2-1": "To shutdown the SDK and perform cleanup",
"2-2": "No",
"2-4": "Yes/ Yes",
"3-0": "getDeviceProfile",
"3-1": "To get the device profile information that is currently\nregistered with the SDK",
"3-2": "No",
"3-4": "Yes/ Yes",
"4-0": "unregister",
"4-1": "To unregisters the current device profile from the IMIconnect\nplatform",
"4-2": "No",
"4-4": "Yes/ Yes",
"5-0": "removeprofiledata",
"5-1": "removes a parameter of the current device profile from the\nIMIconnect platform",
"5-2": "current device profile",
"5-4": "Yes/ Yes",
"6-0": "getDeviceId",
"6-1": "To initialize the registration flow",
"6-2": "No",
"6-4": "Yes/ Yes",
"7-0": "isRegistered",
"7-1": "To check whether the user is currently registered with\nIMIconnect",
"7-2": "No",
"7-3": "true / false",
"7-4": "Yes/ Yes",
"8-0": "getPolicyPollingInterval",
"8-1": "To get the current policy polling interval in\nminutes",
"8-2": "No",
"8-3": "polling intervals",
"8-4": "Yes/ Yes",
"9-0": "registerSecurityTokenExceptionListener",
"9-1": "To register an object to listen for\nSecurity Token related exceptions",
"9-2": "No",
"9-4": "Yes/ No",
"10-0": "unRegisterSecurityTokenExceptionListener",
"10-1": "To unregister a previously\nregistered Security Token related exceptions",
"10-2": "No",
"10-4": "Yes/ No",
"11-0": "setLogOptions",
"11-1": "It sets the log options for the logger.",
"11-2": "No",
"11-3": "",
"11-4": "Yes/ Yes",
"12-0": "startup",
"12-1": "To Initialize the logging system",
"12-2": "No",
"12-4": "Yes/ Yes",
"13-0": "register",
"13-1": "It registers a given device profile with the IMIconnect platform",
"13-2": "No",
"13-4": "Yes/ Yes",
"14-0": "getCachedFile",
"14-1": "To check if a file exists for a URL",
"14-2": "File URL",
"14-3": "file",
"14-4": "Yes/ Yes",
"15-0": "uploadFile",
"15-1": "To upload a file to connect platform",
"15-2": "File URL",
"15-4": "Yes/ Yes",
"16-0": "isStarted",
"16-1": "To verify whether ICMessaging is started or not",
"16-2": "No",
"16-3": "true/false",
"16-4": "Yes/ No",
"17-0": "allowJavascriptInWebviews",
"17-1": "To enable JavaScript execution",
"17-2": "allowWebViews flag",
"17-3": "true/false",
"17-4": "Yes/ No",
"18-0": "setRetentionDuration",
"18-1": "It sets the retention duration of the logs",
"18-2": "Days flag",
"18-4": "Yes/ Yes",
"19-0": "getOutputLocation",
"19-1": "To get the default output location",
"19-2": "No",
"19-3": "Default output\nlocation",
"19-4": "Yes/ No",
"20-0": "downloadFile",
"20-1": "to download a file from a URL",
"20-2": "file URL",
"20-4": "Yes/ Yes",
"21-0": "isFileDownloading",
"21-1": "To check if the manager is currently downloading a file at\na URL.",
"21-2": "File URL",
"21-3": "true/false",
"21-4": "Yes/ Yes",
"22-0": "isFileUploading",
"22-1": "To check if the manager is currently uploading a file",
"22-2": "File\npath",
"22-3": "true/false",
"22-4": "Yes/ Yes",
"23-0": "isMessageStarted",
"23-1": "To verify whether ICMessaging is started or not",
"23-2": "No",
"23-4": "Yes/ No",
"24-0": "connect",
"24-1": "To establish a connection to receive Real Time Messages from\nIMIconnect platform",
"24-2": "No",
"24-4": "Yes/ Yes",
"25-0": "disconnect",
"25-1": "To disconnect the connection between the app and IMIconnect\nplatform",
"25-2": "No",
"25-4": "Yes/ Yes",
"26-0": "getLogPath",
"26-1": "To get the log path",
"26-2": "No",
"26-3": "log path",
"26-4": "No/ Yes"
},
"cols": 5,
"rows": 27
}
[/block]
##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.
[block:code]
{
"codes": [
{
"code": "public class YOUR_APP_NAME extends IMIconnectApplication {\n @Override\n public void onCreate() {\n super.onCreate(); // Call to super.onCreate() will initialize the IMIconnect SDK , reads the configuration from app manifest\n }\n \n // Password to generate encryption key for secure preferences\n @Override\n protected String getPassword()\n {\n return \"YOUR_PASSWORD\";\n }\n}",
"language": "javascript",
"name": "Code"
}
]
}
[/block]
**Add your application class in AndroidManifest.xml file**
[block:code]
{
"codes": [
{
"code": "<application\n android:name=\"YOUR_APP_NAME\"\n android:allowBackup=\"true\"\n android:label=\"@string/app_name\"\n android:theme=\"@style/AppTheme\">\n <activity\n android:name=\"YOUR_ACTIVITY_NAME\"\n android:label=\"@string/app_name\">\n <intent-filter>\n <category android:name=\"android.intent.category.DEFAULT\"/>\n <category android:name=\"android.intent.category.BROWSABLE\"/>\n \n <action android:name=\"android.intent.action.MAIN\"/>\n <category android:name=\"android.intent.category.LAUNCHER\"/>\n </intent-filter>\n \n </activity>\n\n</application>\n",
"language": "xml",
"name": "Code"
}
]
}
[/block]
##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**
[block:parameters]
{
"data": {
"0-0": "Notification",
"0-1": "createNotification(Context context, ICMessage message, int notificationId, Bitmap bigPicture)",
"1-1": "getActionId(String action, String identifier, ICMessage message)",
"2-1": "onBuildNotification(Context context, Builder builder, ICMessage message, int notificationId)",
"1-0": "Int",
"2-0": "void"
},
"cols": 2,
"rows": 3
}
[/block]
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.
[block:code]
{
"codes": [
{
"code": "<receiver\n android:name=\"YOUR_MESSAGE_RECEIVER_NAME\"\n android:enabled=\"true\"\n android:exported=\"true\"\n android:permission=\"com.google.android.c2dm.permission.SEND\">\n <intent-filter>\n <action android:name=\"com.google.android.c2dm.intent.REGISTRATION\"/>\n <action android:name=\"com.imimobile.connect.core.rtmevent\"/>\n <action android:name=\"com.imimobile.connect.core.notification.click\"/>\n <action android:name=\"com.imimobile.connect.core.intent.notification.RECEIVE\"/>\n </intent-filter>\n </receiver>",
"language": "xml"
}
]
}
[/block]
**Public Methods**
[block:parameters]
{
"data": {
"0-0": "Void",
"0-1": "getNotificationFactory()",
"1-1": "onConnectionStatusChanged(Context context, ICConnectionStatus status, ICException exception)",
"2-1": "onMessageReceived(Context context, ICMessage message)",
"1-0": "Void",
"2-0": "Void"
},
"cols": 2,
"rows": 3
}
[/block]
###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.
Updated about 5 years ago