Storage and Synchronization (Discontinued)

🚧

Note

Please note that we have announced end of sale for Cordova SDK. It is no longer offered as a standard Webex Connect capability.

saveMessage

This method saves single ICMessage

ParameterTypeDescription
messageICMessageThe 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
Return Value: Returns true if message storage completes, false Otherwise

ParameterTypeDescription
messagesICMessage[]The array of ICMessages to be saved
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.

ParameterTypeDescriptions
transactionIdStringThe 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 ICMessage from local storage based on threadId and submitted date with a specific limit

ParameterTypeDescription
threadIdStringThe threadId to be retrieved from local storage
submittedBeforeDateThe submittedBefore to be used to fetch messages before submittedBefore from local storage
submittedAfterDateThe submittedAfter to be used to fetch messages after submittedAfter from local storage
limitIntegerThe limit to be used to fetch limited number of messages from local storage

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

IMIconnectPlugin.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);

deleteMessage

Invoke deleteMessage to delete the given message transaction id from the Webex Connect 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);

deleteMessageFromStore

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

ParameterTypeDescription
transactionIdStringThe 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.

ParameterTypeDescription
threadIdStringThe 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

ParameterTypeDescription
threadICThreadThe 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

ParameterTypeDescription
threadsICThread[]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

ParameterTypeDescription
threadIdStringThe 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

ParameterTypeDescription
modifiedBeforeDateThe modifiedBefore(Date instance) to be used to fetch threads modified before from local storage
modifiedAfterDateThe modifiedAfter(Date instance) to be used to fetch threads modified after from local storage
limitIntegerThe limit to be used to fetch limited number of threads from local storage

Return Value: Returns array of ICThreads instance, if threads exist between before & after the modified date with a 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.

ParamterTypeDescription
limitIntegerThe 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

ParameterTypeDescription
threadIdStringThe 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 Webex Connect 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 Webex Connect 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);

setMessageSyncPolicy:

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

ParameterTypeDescription
policyICMessageSynchronizationPolicyMessage 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);

InitDefaultMessageStore

Initializes an encrypted Message Store with given password.

ParameterTypeDescription
passwordStringA password that is used to protect the database via encryption. The host application is responsible for ensuring the security of the password.
IMIconnectPlugin.initDefaultMessageStore(function (status) { 
console.log("initDefaultMessageStore status" + status); 
}, function (error) { 
console.log('initDefaultMessageStore Failed :' + error); 
}, password);