MessageStore

Represents the message storage.

Represents the message storage. This interface provides all the methods to save, load, and delete messages and threads from local storage.

Functions

NameReturn TypeDescription
deleteAllBooleanDeletes complete threads & messages
deleteMessageBooleanDeletes single InAppMessage from local storage based on transactionId
deleteThreadBooleanDeletes single InAppThread from local storage based on threadId
getMessageCountIntGives the count of messages from local storage based on threadId
getThreadCountIntGives the total number of threads count from local storage
getUnreadMessageCountStringGives the count of messages from local storage based on threadId
getUnreadThreadCountIntGives the count of unread messages threads count
loadMessageStringLoads single InAppMessage from local storage based on transactionId
loadMessagesStringLoads InAppMessage from local storage based on threadId and submitted date with a specific limit
loadThreadStringLoads single InAppThread from local storage based on threadId
loadThreadsIntLoads InAppThreads from local storage based date modifiedBefore with a specific limit
loadUnreadThreadsIntLoads unread InAppThreads from local storage with a specific limit
saveMessageBooleanSaves multiple InAppMessages
saveThreadBooleanSaves multiple InAppThreads

deleteAll

This method deletes complete InAppThreads & InAppMessages.

Syntax: fun MessageStore.deleteAll(callback: (Boolean) -> Unit)

Return Value: Returns true if deletion completes, false otherwise.

deleteMessage

This method deletes a single InAppMessage from local storage based on transactionId.

Syntax: fun MessageStore.deleteMessage(transactionId: String, callback: (Boolean) -> Unit)

Return Value: Returns true if delete message completes, false otherwise.

Parameters

ParametersTypeDescription
transactionIdStringThe transactionId is to be deleted from local storage.

deleteThread

This method allows us to delete a single InAppThread from local storage based on threadId

Syntax: fun MessageStore.deleteThread(threadId: String, callback: (Boolean) -> Unit)

Return Value: Returns true if delete thread completes, false otherwise.

Parameters:

ParametersTypeDescription
threadIdStringThe threadId to be deleted from local storage

getMessageCount

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

Syntax: fun MessageStore.getMessageCount(threadId: String, callback: (Int) -> Unit)

Return Value: Returns count of messages.

Parameters

ParametersTypeDescription
threadIdStringThe threadId to be fetched count from local storage

getThreadCount

This method provides the total number of threads count from local storage.

Syntax: fun MessageStore.getThreadCount(callback: (Int) -> Unit)

Return Value: Returns count of threads.

getUnreadMessageCount

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

Syntax: fun MessageStore.getUnreadMessageCount(threadId: String, callback: (Int) -> Unit)

Return Value: Returns count of unread messages.

Parameters

ParametersTypeDescription
threadIdStringthe threadId to be fetched count from local storage

getUnreadThreadCount

This method gives the total number of threads containing unread messages.

Syntax: fun MessageStore.getUnreadThreadCount(callback: (Int) -> Unit)

Return Value: The number of threads containing unread messages.

loadMessage

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

Syntax: fun MessageStore.loadMessage(transactionId: String, callback: (InAppMessage?) -> Unit)

Return Value: Returns InAppMessage instance if a message exists with transactionId.

Parameters

ParametersTypeDescription
transactionIdStringthe transactionId to be retrieved from local storage

loadMessages

This method loads messages from local storage for a specific thread, based on optional date parameters submittedBefore and submittedAfter, with the specified limit.

Syntax: fun MessageStore.loadMessages(threadId: String, limit: Int, submittedBefore: Date? = null, submittedAfter: Date? = null, callback: (List<InAppMessage>) -> Unit)

Return Value: Array of InAppMessage instance if messages exist with threadId.

Parameters

ParametersTypeDescription
threadIdStringThe threadId to be retrieved from local storage
limitIntthe limit to be used to fetch limited number of messages from local storage
submittedBeforeDatethe submittedBefore to be used to fetch messages before the submitted time from local storage
submittedAfterDatethe submittedAfter to be used to fetch messages after the submitted time from local storage

loadThread

This method loads a specific InAppThread from local storage based on the provided threadId.

Syntax: fun MessageStore.loadThread(threadId: String, callback: (InAppThread?) -> Unit)

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

Parameters:

ParametersTypeDescription
threadIdStringThe threadId to be retrieved from local storage
callbackInAppThread

loadThreads

This method Loads InAppThreads from local storage based date modifiedBefore with the specific limit.

Syntax: fun MessageStore.loadThreads(limit: Int, modifiedBefore: Date? = null, modifiedAfter: Date? = null, callback: (List<InAppThread>) -> Unit)

Return: Returns array of InAppThread instances, if threads exists between before & after modified date with limit.

Parameters

ParametersTypeDescription
limitIntThe limit to be used to fetch limited number of threads from local storage
modifiedBeforeDateThe modifiedBefore to be used to fetch threads modified before from local storage
modifiedAfterDateThe modifiedAfter to be used to fetch threads modified after from local storage

loadUnreadThreads

This method loads unread InAppThreads containing at least one unread message from local storage with specific limit.

Syntax: fun MessageStore.loadUnreadThreads(limit: Int, callback: (List<InAppThread>) -> Unit)

Return Value: An array of InAppThread instances with some unread messages.

Parameters:

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

saveMessage

This method saves multiple InAppMessages.

Syntax: fun MessageStore.saveMessage(vararg messages: InAppMessage, callback: (Boolean) -> Unit)

Return: Returns true if message storage completes, false otherwise.

Parameters:

ParametersTypeDescription
messagesInAppMessagethe array of InAppMessages to be saved

saveThread

This method saves multiple InAppThreads.

Syntax: fun MessageStore.saveThread(vararg threads: InAppThread, callback: (Boolean) -> Unit)

Return value: Return true if thread storage completes, false otherwise.

Parameters:

ParametersTypeDescription
threadsInAppThreadthe array of InAppThreads to be saved