Storage & Synchronization
Message Storage:
Message Synchronization:
ICMessageStore
This interface defines the methods used to persist and retrieve data related to In App Messages from an underlying data persistence mechanism. The message store capability is enabled by passing a ICMessageStore implementation to the SDK via ICMessaging.setMessageStore.
Implementors of the interface should ensure they comply with the intentions of each method as documented below.
Methods:
deleteAll
Deletes all data from the store.
Syntax: boolean deleteAll()
Return Value: true
if the operation is successful, otherwise false
deleteMessage
Deletes a single message that matches the provided transaction id.
Syntax: boolean deleteMessage(String transactionId)
Parameters
Parameter | Type | Description |
---|---|---|
transactionId | String | The transactionId of the message that should be deleted |
Return Value: true
if the message was deleted otherwise false
.
deleteThread
Deletes a single thread that matches the provided thread id.
Syntax: boolean deleteThread(String threadId)
Parameters
Parameter | Type | Description |
---|---|---|
threadId | String | The id of the thread to be deleted |
Return Value: true
if the thread was deleted, otherwise false
.
getMessageCount
Gets the total count of messages that belong to the provided thread id.
Syntax: int getMessageCount(String threadId)
Parameters
Parameter | Type | Description |
---|---|---|
threadId | String | The id of the thread whose message count should be returned. |
Return Value: The count of messages contained within the store for the provided thread id.
getThreadCount
Gets the total number of threads contained within the store.
Syntax: int getThreadCount()
Return Value:The count of threads contained within the store.
getUnreadMessageCount
Get the total count of unread messages that are contained within the store for the provided thread id.
Syntax: long getUnreadMessageCount(String threadId)
Parameters
Parameter | Type | Description |
---|---|---|
threadId | String | The id of the thread whose unread message count should be returned. |
Return Value: The count of unread messages contained within the store for the provided thread id.
getUnreadThreadCount
Gets the total number of unread threads contained within the store. A thread is considered as unread if it has at least one unread message.
Syntax: int getUnreadThreadCount()
Return Value:The count of unread threads contained within the store.
loadMessage
Loads a single ICMessage from the store that matches the provided transaction id.
Syntax: ICMessage loadMessage(String transactionId)
Parameters
Parameter | Type | Description |
---|---|---|
transactionId | String | The transaction id of the message to be retrieved from the store |
Return Value: An ICMessage instance if a match exists within the store, otherwise null
Loads an array of [ICMessage](doc:core-messaging#section-icmessage) that match the provided parameters. The result set is ordered newest to oldest.
Syntax: ICMessage[] loadMessages(String threadId, Date submittedBefore, Date submittedAfter, int limit)
Parameters
Parameter | Type | Description |
---|---|---|
threadId | String | The id of the thread to which the messages must belong |
submittedBefore | Date | Filters the result set to contain messages whose submittedAt date is before the specified date. If a null value is passed, the behaviour should be similar to passing the current device date. |
submittedAfter | Date | Filters the result set to contain messages whose submittedAt date is after the specified date. If a null value is passed, the behaviour should be similar to passing the current device date. |
limit | int | Limits the number of messages returned in the result set. |
Return Value: An array of [ICMessage](doc:core-messaging#section-icmessage) instances that match the provided parameters.
loadMessages
Loads an array of [ICMessage](doc:core-messaging#section-icmessage) that match the provided parameters. The result set is ordered newest to oldest.
Syntax: ICMessage[] loadMessages(String threadId, Date submittedBefore, Date submittedAfter, int limit)
Parameters
Parameter | Type | Description |
---|---|---|
threadId | String | The id of the thread to which the messages must belong |
submittedBefore | Date | Filters the result set to contain messages whose submittedAt date is before the specified date. If a null value is passed, the behaviour should be similar to passing the current device date. |
limit | int | Limits the number of messages returned in the result set. |
Return Value: An array of [ICMessage](doc:core-messaging#section-icmessage) instances that match the provided parameters.
loadThread
Loads a single [ICThread](doc:core-messaging#section-icthread) that matches the provided id.
Syntax: ICThread[] loadThread(String threadId)
Parameters
Parameterq | Type | Descriptioin |
---|---|---|
threadId | String | The id of the thread to be retrieved |
Return Value: Returns an [ICThread](doc:core-messaging#section-icthread) instance if a match exists within the store, otherwise null
Loads an array of [ICThread](doc:core-messaging#section-icthread) that match the provided parameters. The result set is ordered newest to oldest.
Syntax: ICThread[] loadThreads(Date modifiedBefore, Date modifiedAfter, int limit)
Parameters
Parameter | Type | Description |
---|---|---|
modifiedBefore | Date | Filters the result set to contain threads whose modifiedDate is before the provided date. If a null value is passed, the behaviour should be similar to passing the current device date. |
modifiedAfter | Date | Filters the result set to contain threads whose modifiedDate is after the provided date. If a null value is passed, the behaviour should be similar to passing the current device date. |
limit | int | Limits the number of threads returned in the result set. |
Return Value: An array of [ICThread](doc:core-messaging#section-icthread) instances that match the provided criteria.
loadThreads
Loads an array of [ICThread](doc:core-messaging#section-icthread) that match the provided parameters. The result set is ordered newest to oldest.
Syntax: ICThread[] loadThreads(Date modifiedBefore, int limit)
Parameters
Parameter | Type | Description |
---|---|---|
modifiedBefore | Date | Filters the result set to contain threads whose modifiedDate is before the provided date. If a null value is passed, the behaviour should be similar to passing the current device date. |
limit | int | Limits the number of threads returned in the result set. |
Return Value: An array of [ICThread](doc:core-messaging#section-icthread) instances that match the provided criteria.
loadUnreadThreads
Loads an array of unread [ICThread](doc:core-messaging#section-icthread) instance, a thread is considered unread if it contains at least one unread message. The result set is ordered newest to oldest.
Syntax: ICThread[] loadUnreadThreads(int limit)
Parameters
Parameter | Type | Description |
---|---|---|
limit | int | Limits the number of threads returned in the result set. |
Return Value: An array of [ICThread](doc:core-messaging#section-icthread) instances that match the provided criteria.
saveMessage
Saves a single [ICMessage](doc:core-messaging#section-icmessage) to the store.
Syntax: boolean saveMessage(ICMessage message)
Parameters
Parameter | Type | Description |
---|---|---|
Message | [ICMessage](doc:core-messaging#section-icmessage) | The message to be saved to the store. |
Return Value: true
if the message was stored, otherwise false
saveMessages
Saves an array of [ICMessage](doc:core-messaging#section-icmessage) to the store.
Syntax: boolean saveMessages(ICMessage[] messages)
Parameters
Parameter | Type | Description |
---|---|---|
messages | [ICMessage](doc:core-messaging#section-icmessage) | The array of messages to be saved to the store |
Return Value: true
if the messages were stored, otherwise false
.
saveThread
Saves a single [ICThread](doc:core-messaging#section-icthread) to the store.
Syntax: boolean saveThread(ICThread thread)
Parameters
Parameter | Type | Description |
---|---|---|
thread | [ICThread](doc:core-messaging#section-icthread) | The thread to be saved to the store |
Return Value: true
if the thread was saved, otherwise false
.
saveThreads
Saves an array of [ICThread](doc:core-messaging#section-icthread) instances to the store.
Syntax: boolean saveThreads(ICThread[] threads)
.
Parameters
Parameter | Type | Description |
---|---|---|
threads | [ICThread](doc:core-messaging#section-icthread)[] | The array of threads to be saved to the store |
Return Value: true
if the threads were saved, otherwise false
.
ICDefaultMessageStore
Default implementation of [ICMessageStore](#section-icmessagestore) that persists data to an encrypted SQLite database.
Constructors
Deprecated - Use [ICDefaultMessageStore(Context context, String dbPassword)](#section-icdefaultmessagestore-a-pw-) instead.
Instantiates an ICDefaultMessageStore instance that is not encrypted.
Syntax: ICDefaultMessageStore(final @NonNull Context context)
Parameter
Parameter | Description |
---|---|
context | A valid Android context instance |
Syntax: ICDefaultMessageStore(final @NonNull Context context, final @NonNull String dbPassword)
Instantiates an encrypted ICDefaultMessageStore instance.
Parameters
Parameter | Description |
---|---|
context | Specifies the Android context. |
dbPassword | Password that is used to protect the database via encryption. The host application is responsible for ensuring the security of the password. |
ICMessageSynchronizer
The message synchronizer may be used to enable synchronization of In App messages between the IMIconnect platform and the SDK. Synchronization occurs automatically based on the policy settings supplied to the synchronizer.
Message synchronization is disabled by default.
Return Type | Method |
---|---|
void | [setPolicy(ICMessageSynchronizationPolicy)](#section-setpolicy) |
setPolicy
Sets the policy object which controls the extent of In App message data that should be synchronized.
Syntax: void setPolicy(ICMessageSynchronizationPolicy policy)
Parameters
Parameter | Type | Description |
---|---|---|
policy | [ICMessageSynchronizationPolicy](#section-icmessagesynchronizationpolicy) | A valid policy instance. Passing null will cause the method to fail gracefully, but any previously set policy will continue to apply. |
ICMessageSynchronizationPolicy
Describes the extent of message synchronization that should occur. A synchronization policy is a combination of mode and limit attributes that describe whether no, limited or full synchronization should occur.
Return Type | Method |
---|---|
void | [setMode(ICMessageSynchronizationMode mode)](#section-setmode) |
void | [setLimits(int maxThreads, int maxMessagesPerThread)](#section-setlimits) |
setMode
Sets the mode of synchronization, either None, Limited or Full.
Syntax: void setMode(ICMessageSynchronizationMode mode)
Parameters
Parameter | Type | Description |
---|---|---|
mode | [ICMessageSynchronizationMode](doc:enumerations#section-icmessagesynchronizationmode) | A valid mode setting of None, Limited or Full. |
setLimits
Sets the maximum number of threads, and maximum number of messages per thread, which will be synchronized. Limits only apply when the synchronization mode is set to Limited.
Syntax: void setLimits(int maxThreads, int maxMessagesPerThread)
Parameters
Parameter | Type | Description |
---|---|---|
maxThreads | int | The maximum number of threads that will be synchronized |
maxMessagesPerThread | int | The maximum number of messages per thread that will be synchronized |
Updated almost 2 years ago