STWMessagesApi

object STWMessagesApi : ObservableApi

Functions

Link copied to clipboard
suspend fun assignAdminsToConversation(    context: Context,     conversationId: Int,     users: List<STWRecipientSingle>,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to assign a new member as an admin to the given group conversation

Link copied to clipboard
suspend fun changeGroupName(    context: Context,     conversationId: Int,     newConversationName: String,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to change the conversation name for the given conversation to the newGroupName.

Link copied to clipboard
suspend fun closeGroupConversation(    context: Context,     conversationId: Int,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to close the given group conversation ConversationTypes.GROUP

Link copied to clipboard
fun confirmAckMessageReception(    context: Context,     messageId: Int?,     callback: OperationListener<MessagingError>?)

Call this method to confirm the reception of an acknowledged message.

Link copied to clipboard
suspend fun createAndSendVideoConferenceLink(    context: Context,     conversationId: Int?,     title: String?,     description: String?,     startDatetimeStamp: Long? = null,     endDateTimeStamp: Long? = null): ApiResult<Int>

Call this method to create and send a new conference link for an existing conversation.

Link copied to clipboard
fun createConversation(    context: Context,     conversationName: String?,     conversationType: Int,     recipients: List<STWRecipient>,     isAvailableOnlyRecipients: Boolean,     callback: CreationConversationCallback?)

Call this method to create a new conversation, The created conversation will be empty.

Link copied to clipboard
suspend fun deleteConversations(    context: Context,     conversationIds: List<Int>,     callback: (result: Boolean) -> Unit?)

Call this method to delete an existing list of conversations.

Link copied to clipboard
fun deleteMessage(    context: Context,     messageId: Int?,     callback: CompletionCallback?)

Call this method to delete an existing message from local Database and server.

Link copied to clipboard
fun deleteMessages(    context: Context,     messageList: List<Int>,     callback: CompletionCallback?)

Call this method to delete an existing list of messages.

Link copied to clipboard
fun enableMessagesAutoDeletionTask(    context: Context,     enable: Boolean,     periodInMilliSecond: Long? = null)

Call this method to enable or disable the message auto deletion task When enabled, set the period of time after which the messages will be deleted permanently in milli seconds, null otherwise

Link copied to clipboard
fun flowSearchConversations(    context: Context,     query: String? = null,     onlyUnread: Boolean = false,     ascOrder: Boolean = false,     @IntRange(from = 0) limit: Int = 100): Flow<List<ConversationSearchResult>?>

This function retrieves conversations following these rules :

Link copied to clipboard
fun flowSearchMessages(    context: Context,     query: String? = null,     contactQuery: String? = null,     mediaFilter: MediaFilter = MediaFilter.None,     ascOrder: Boolean = false,     @IntRange(from = 0) limit: Int = 100): Flow<List<MessageSearchResult>?>

This function retrieves conversations according to the query, contactQuery&mediaFilter based on :

Link copied to clipboard
fun forwardMessages(    context: Context,     conversationId: Int?,     messageIds: List<Int>,     callback: CompletionCallback?,     progressChanged: (attachmentId: Int, progress: Int, total: Int) -> Unit? = null)

Call this method to forward messages to another existing conversation.

This method does not allow :

  • an empty message Id list
  • a none existing conversation

Link copied to clipboard
fun getAdminsOfConversationAsFlow(context: Context, conversationId: Int): Flow<List<STWSingleContact>?>

Call this method to retrieve list of all administrators of the given conversation (Regular admins and admin initiator) as flow

Link copied to clipboard
fun getAdminsOfConversationAsLiveData(context: Context, conversationId: Int): LiveData<List<STWSingleContact>?>

Call this method to retrieve list of all administrators of the given conversation (Regular admins and admin initiator) as LiveData

Link copied to clipboard
fun getAllowedFeaturesAsFlow(    featureName: String,     coroutineScope: CoroutineScope,     lifecycleOwner: LifecycleOwner): StateFlow<Boolean>
fun getAllowedFeaturesAsFlow(    featureName: String,     coroutineScope: CoroutineScope,     getDisposable: (disposable: Disposable) -> Unit): StateFlow<Boolean>

Call this method to check whether the messaging feature is allowed or not.

Link copied to clipboard
fun getCompanyConversations(    context: Context,     withFullData: Boolean = false,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the full company conversations

suspend fun getCompanyConversations(    context: Context,     withFullData: Boolean = false,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this suspended method to retrieve list of company conversations

Link copied to clipboard
suspend fun getContactsInConversation(context: Context, conversationId: Int): List<STWContact>?

Call this method to retrieve the full list of contacts in the conversation

Link copied to clipboard
suspend fun getConversationByConversationGroupId(context: Context, conversationGroupId: String): Flow<STWConversation?>

Call this method to retrieve the conversation represented by STWConversation object given a conversationId.

Link copied to clipboard
suspend fun getConversationById(context: Context, conversationId: Int?): STWConversation?

Call this method to retrieve the conversation represented by STWConversation object given a conversationId.

Link copied to clipboard
fun getConversationByIdAsFlow(context: Context, conversationId: Int): Flow<STWConversation?>

Get the conversation having a specified Id as Flow.

Link copied to clipboard
fun getConversationByIdAsLiveData(context: Context, conversationId: Int): LiveData<STWConversation?>

Get the conversation having a specified Id as LiveData.

Link copied to clipboard
suspend fun getConversationBySingleContact(context: Context, recipient: STWContact?): STWConversation?
fun getConversationBySingleContact(    context: Context,     recipient: STWContact?,     completion: (STWConversation?) -> Unit)

Call this method to retrieve a one to one conversation from local Database given the recipient represented bySTWContact.

suspend fun getConversationBySingleContact(context: Context, recipient: STWSingleContact?): STWConversation?

Call this method to retrieve a one to one conversation from local Database given the recipient represented bySTWSingleContact.

Link copied to clipboard
fun getConversations(context: Context, pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Get the list of all conversations (Company conversations and external conversation).

suspend fun getConversations(    context: Context,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this method to retrieve list of conversations by page

Link copied to clipboard
suspend fun getConversationsByGroupContactId(    context: Context,     groupContactId: String,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this method to retrieve the list of company conversations given.

Link copied to clipboard
fun getDefaultPageConfig(): PagingConfig
Link copied to clipboard
suspend fun getDeliveryReportListByMessageId(    context: Context,     messageId: String,     @IntRange(from = 0) from: Int? = null,     @IntRange(from = 1) pageSize: Int? = null,     ascOrder: Boolean = true): List<STWDeliveryReport>?

Call this method to retrieve all message deliveries given a message id from local Database and it should be called only from a coroutine or another suspend function

fun getDeliveryReportListByMessageIdAndStateAsLiveData(    context: Context,     messageId: String,     vararg states: Int): LiveData<List<STWDeliveryReport>?>

Call this method to retrieve all message deliveries LiveData given a message id and list of states from local Database.

fun getDeliveryReportListByMessageIdAsLiveData(context: Context, messageId: String): LiveData<List<STWDeliveryReport>?>

Call this method to retrieve all message deliveries LiveData given a message id from local Database.

Link copied to clipboard
suspend fun getDraftMessageByConversationId(context: Context, conversationId: Int?): STWBaseMessage?

Call this method to retrieve the draft message given conversationId from local Database represented by STWBaseMessage.

Link copied to clipboard
fun getExternalConversations(    context: Context,     withFullData: Boolean = false,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the external conversations

suspend fun getExternalConversations(    context: Context,     withFullData: Boolean = false,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this suspended method to retrieve list of external conversations

Link copied to clipboard
suspend fun getGroupsInConversation(    context: Context,     conversationId: Int,     @IntRange(from = 0) from: Int? = null,     @IntRange(from = 1) pageSize: Int? = null): List<STWGroup>?

Call this method to retrieve recipient groups in the given conversation and it should be called only from a coroutine or another suspend function

Link copied to clipboard
fun getGroupsOfConversationAsFlow(context: Context, conversationId: Int): Flow<List<STWGroup>?>

Call this method to retrieve recipient groups in the given conversation as Flow

Link copied to clipboard
fun getGroupsOfConversationAsLiveData(context: Context, conversationId: Int): LiveData<List<STWGroup>?>

Call this method to retrieve recipient groups in the given conversation as LiveData

Link copied to clipboard
fun getMessageAutoDeletionPeriod(context: Context): Long

Get the period of time after which the messages will be deleted permanently

Link copied to clipboard
suspend fun getMessageByMessageId(context: Context, messageId: Int?): STWBaseMessage?

Call this method to retrieve the message represented by STWBaseMessage object given a messageId.

Link copied to clipboard
fun getMessageByMessageIdAsLiveData(context: Context, messageId: Int): LiveData<STWBaseMessage?>

Get the message having a specified Id as LiveData.

Link copied to clipboard
fun getMessagePosition(    context: Context,     messageServerDate: String,     threadId: String): Int

Call this method to get the message position in the conversation.

Link copied to clipboard
suspend fun getMessagePositionInConversation(    context: Context,     conversationId: Int,     messageServerDate: String): Int?

Call this method to get the message position in the conversation.

Link copied to clipboard
fun getMessagesByThreadId(    context: Context,     conversationId: Int,     messagePosition: Int? = null,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWBaseMessage>>

Get the list of messages having the specified conversation Id.

suspend fun getMessagesByThreadId(    context: Context,     conversationId: Int,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWBaseMessage>?

Get the list of messages related to the specified conversation Id.

fun getNumberOfConversationsForRecipientGroupId(context: Context, groupContactId: String): Int

Call this method to retrieve the number of the related conversations for a given groupId. Means all conversation with only the given groupId as a recipient.

Link copied to clipboard
fun getPagedConversations(context: Context, ascOrder: Boolean = false): PagingSource<Int, STWConversation>

Loading page of conversations related to a specified conversationId.

Link copied to clipboard
fun getPagedMessagesByThreadId(    context: Context,     conversationId: Int,     ascOrder: Boolean = false): PagingSource<Int, STWBaseMessage>

Loading page of messages related to a specified conversationId.

Link copied to clipboard
fun getPagingConversationByGroupContactId(    context: Context,     groupContactId: String,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the list of company conversations given.

Link copied to clipboard
fun getPagingSourceOfCompanyConversations(    context: Context,     withFullData: Boolean = false,     ascOrder: Boolean = false): PagingSource<Int, STWConversation>

Call this method to retrieve list of company conversations

Link copied to clipboard
fun getPagingSourceOfExternalConversations(    context: Context,     withFullData: Boolean = false,     ascOrder: Boolean = false): PagingSource<Int, STWConversation>

Call this method to retrieve list of external conversations

Link copied to clipboard
suspend fun getRecipientsInConversation(context: Context, conversationId: Int): List<STWContact>

Call this method to retrieve both single (without admins) and group recipients in the given conversation

Link copied to clipboard
fun getRecipientsInConversationAsFlow(context: Context, conversationId: Int): Flow<List<STWContact>?>

Call this method to retrieve both single (without admins) and group recipients in the given conversation

Link copied to clipboard
fun getRecipientsInConversationAsLiveData(context: Context, conversationId: Int): LiveData<List<STWContact>?>

Call this method to retrieve both single (without admins) and group recipients in the given conversation

Link copied to clipboard
suspend fun getRegularAdminsOfConversation(    context: Context,     conversationId: Int,     @IntRange(from = 0) from: Int? = null,     @IntRange(from = 1) pageSize: Int? = null): List<STWContact>?

Call this method to retrieve list of regular administrator in group conversation and it should be called only from a coroutine or another suspend function

Link copied to clipboard
suspend fun getSingleContactsInConversation(    context: Context,     conversationId: Int,     @IntRange(from = 0) from: Int? = null,     @IntRange(from = 1) pageSize: Int? = null): List<STWSingleContact>?

Call this method to retrieve single recipients in the given conversation and it should be called only from a coroutine or another suspend function

Link copied to clipboard
fun getSingleContactsOfConversationAsFlow(context: Context, conversationId: Int): Flow<List<STWSingleContact>?>

Call this method to retrieve single recipients in the given conversation as Flow

fun getSingleContactsOfConversationAsLiveData(context: Context, conversationId: Int): LiveData<List<STWSingleContact>?>

Call this method to retrieve single recipients in the given conversation as LiveData

Link copied to clipboard
fun getUnreadThreadCount(context: Context): LiveData<Int>

Call this method to get the number of unread conversations.

Link copied to clipboard
fun handleDraftMessage(    context: Context,     conversationId: Int?,     text: String? = null,     attachment: Attachment? = null,     isFromNfc: Boolean = false,     callback: CompletionCallback?)

Call this method to add, update or remove drafts in conversations from local database.

Link copied to clipboard
suspend fun inviteParticipantToConversation(    context: Context,     conversationId: Int,     recipients: List<STWRecipient>,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to invite new participants (users and/or groups) to the conversation.

Link copied to clipboard
fun isMessageAckAllowed(context: Context): Boolean

Call this method to check whether the message acknowledgement feature is enabled or not.

Link copied to clipboard
fun isMessageReadConfirmationAllowed(context: Context): Boolean

Call this method to check whether the seen message feature is enabled from user settings or not.

Link copied to clipboard
fun isVoiceMailAllowed(context: Context): Boolean
Link copied to clipboard
suspend fun leaveGroupConversation(    context: Context,     conversationId: Int,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to leave a group conversation.

Link copied to clipboard
suspend fun loadMessages(    context: Context,     conversationId: Int?,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to load messages of the given conversation.

Link copied to clipboard
suspend fun loadMoreMessages(    context: Context,     conversationId: Int?,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to load more messages of configured conversation.

Link copied to clipboard
fun markConversationAsRead(    context: Context,     conversationId: Int,     callback: OperationListener<MessagingError>?)

Call this method to mark all messages of the conversation as read and synced with back-end.

Link copied to clipboard
suspend fun removeAdminFromConversation(    context: Context,     conversationId: Int,     users: List<STWRecipientSingle>,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to remove a regular admin from the current group conversation, means the adminPhoneNumber will be a simple member

Link copied to clipboard
suspend fun removeGroupsFromConversation(    context: Context,     conversationId: Int,     groups: List<STWRecipientGroup>,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to remove a group from a group conversation.

Link copied to clipboard
suspend fun removeMemberFromConversation(    context: Context,     conversationId: Int,     user: STWRecipientSingle,     timeout: Long = 10000): ApiResult<Boolean>

Call this method to remove a user from a group conversation.

Link copied to clipboard
fun resendMessage(    context: Context,     messageId: Int?,     completionCallback: CompletionCallback? = null,     progressChanged: (attachmentId: Int, progress: Int, total: Int) -> Unit? = null)

Call this method to resend a failed message.

Link copied to clipboard
fun searchAllConversationsAsLiveData(context: Context, searchKey: String): LiveData<List<STWConversation?>>

Call this method to retrieve the list of all conversations.

Link copied to clipboard
fun searchAllConversationsAsPagingData(    context: Context,     searchKey: String,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the list of all conversations.

Link copied to clipboard
suspend fun searchCompanyConversations(    context: Context,     searchKey: String,     withAttachment: Boolean = false,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this method to search for a list of company conversations by content.

Link copied to clipboard
fun searchCompanyConversationsAsLiveData(context: Context, searchKey: String): LiveData<List<STWConversation?>>

Call this method to retrieve the list of company conversations.

Link copied to clipboard
fun searchCompanyConversationsAsPagingData(    context: Context,     searchKey: String,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the list of company conversations.

Link copied to clipboard
suspend fun searchConversations(    context: Context,     query: String? = null,     onlyUnread: Boolean = false,     ascOrder: Boolean = false,     @IntRange(from = 0) limit: Int = 100): List<ConversationSearchResult>?

This function retrieves conversations following these rules :

Link copied to clipboard
fun searchConversationsByTypeAsLiveData(    context: Context,     searchKey: String,     withAttachment: Boolean): LiveData<List<STWConversation?>>

Call this method to retrieve the list of company conversations given.

Link copied to clipboard
fun searchConversationsByTypeAsPagingData(    context: Context,     searchKey: String,     withAttachment: Boolean,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the list of company conversations given.

Link copied to clipboard
suspend fun searchExternalConversations(    context: Context,     searchKey: String,     @IntRange(from = 0) from: Int,     @IntRange(from = 1) pageSize: Int,     ascOrder: Boolean = false): List<STWConversation>?

Call this method to search for a list of external conversations by content.

Link copied to clipboard
fun searchExternalConversationsAsLiveData(context: Context, searchKey: String): LiveData<List<STWConversation?>>

Call this method to retrieve the list of external conversations.

Link copied to clipboard
fun searchExternalConversationsAsPagingData(    context: Context,     searchKey: String,     pagingConfig: PagingConfig = getDefaultPageConfig()): Flow<PagingData<STWConversation>>

Call this method to retrieve the list of external conversations.

fun searchExternalConversationsAsPagingSource(    context: Context,     searchKey: String,     ascOrder: Boolean = false): PagingSource<Int, STWConversation>

Call this method to search for a list of external conversations by content.

Link copied to clipboard
suspend fun searchMessages(    context: Context,     query: String? = null,     contactQuery: String? = null,     mediaFilter: MediaFilter = MediaFilter.None,     ascOrder: Boolean = false,     @IntRange(from = 0) limit: Int = 100): List<MessageSearchResult>?

This function retrieves conversations according to the query, contactQuery&mediaFilter based on :

fun searchOfCompanyConversationsAsPagingSource(    context: Context,     searchKey: String,     withAttachment: Boolean = false,     ascOrder: Boolean = false): PagingSource<Int, STWConversation>

Call this method to search for a list of company conversations by content.

Link copied to clipboard
fun sendMessage(context: Context, builder: MessageRequest.Builder.() -> Unit = {})
fun sendMessage(    context: Context,     message: String?,     attachment: Attachment?,     conversationId: String,     builder: MessageRequest.Builder.() -> Unit = {})

Call this method to send a new message/attachment for an existing conversation.

Inherited functions

Link copied to clipboard
fun subscribe(listener: STWEventListener<STWEvent>): Disposable
Link copied to clipboard
fun subscribeFor(eventTypes: Array<Class<out STWEvent>>, listener: STWEventListener<STWEvent>): Disposable
fun subscribeFor(eventTypes: Array<String>, listener: STWEventListener<STWEvent>): Disposable

Subscribes to the specific eventTypes of the client.

fun subscribeFor(    lifecycleOwner: LifecycleOwner,     eventTypes: Array<Class<out STWEvent>>,     listener: STWEventListener<STWEvent>): Disposable
fun subscribeFor(    lifecycleOwner: LifecycleOwner,     eventTypes: Array<String>,     listener: STWEventListener<STWEvent>): Disposable

Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner.

fun subscribeFor(    eventTypes: Array<String>,     filter: (STWEvent) -> Boolean,     listener: STWEventListener<STWEvent>): Disposable

Subscribes to the specific eventTypes of the client with additional filter.

fun subscribeFor(    lifecycleOwner: LifecycleOwner,     eventTypes: Array<String>,     filter: (STWEvent) -> Boolean,     listener: STWEventListener<STWEvent>): Disposable

Subscribes to the specific eventTypes of the client with additional filter, in the lifecycle of lifecycleOwner.

Link copied to clipboard
fun <T : STWEvent> subscribeForSingle(eventType: Class<T>, listener: STWEventListener<T>): Disposable
fun subscribeForSingle(eventType: String, listener: STWEventListener<STWEvent>): Disposable

Subscribes for the next event with the given eventType.

fun subscribeForSingle(    eventType: String,     filter: (STWEvent) -> Boolean,     listener: STWEventListener<STWEvent>): Disposable

Subscribes for the next event with the given eventType with additional filter.