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

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

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

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

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

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

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

ParameterTypeDescription
threadIdStringThe id of the thread to which the messages must belong
submittedBeforeDateFilters 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.
submittedAfterDateFilters 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.
limitintLimits 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

ParameterTypeDescription
threadIdStringThe id of the thread to which the messages must belong
submittedBeforeDateFilters 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.
limitintLimits 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

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

ParameterTypeDescription
modifiedBeforeDateFilters 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.
modifiedAfterDateFilters 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.
limitintLimits 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

ParameterTypeDescription
modifiedBeforeDateFilters 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.
limitintLimits 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

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

ParameterTypeDescription
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

ParameterTypeDescription
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

ParameterTypeDescription
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

ParameterTypeDescription
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

ParameterDescription
contextA valid Android context instance

  Syntax: ICDefaultMessageStore(final @NonNull Context context, final @NonNull String dbPassword)

Instantiates an encrypted ICDefaultMessageStore instance.

Parameters

ParameterDescription
contextSpecifies the Android context.
dbPasswordPassword 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 TypeMethod
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

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

ParameterTypeDescription
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

ParameterTypeDescription
maxThreadsintThe maximum number of threads that will be synchronized
maxMessagesPerThreadintThe maximum number of messages per thread that will be synchronized