# Chats

class Chats

## Properties

currentChats
Link copied to clipboard
val currentChats: List<Chat>

Contains the list of chat instances associated with the current user.

currentGroupChats
Link copied to clipboard
val currentGroupChats: List<Chat>
currentIndividualChats
Link copied to clipboard
val currentIndividualChats: List<Chat>
currentState
Link copied to clipboard
lateinit var currentState: XmppClient.State

Current XMPP session state.

isFileUploadSupported
Link copied to clipboard
val isFileUploadSupported: Boolean

Returns a Boolean value indicating whether the current XMPPConnection is able to use the file upload feature. If should be called after receiving the event indicating that the xmpp session is authenticated.

rx
Link copied to clipboard
val rx: ChatsRx

## Functions

addChatClientListener
Link copied to clipboard
fun addChatClientListener(listener: ChatClientListener)

Adds a listener to receive different chat client events.

addGroupsChatsListener
Link copied to clipboard
fun addGroupsChatsListener(listener: GroupChatsListener)

Adds a listener to receive different group chat events.

addIndividualChatsListener
Link copied to clipboard
fun addIndividualChatsListener(listener: IndividualChatsListener)

Adds a listener to receive different chats events.

connect
Link copied to clipboard
fun connect(isDebugEnabled: Boolean = false, onCompletion: (SippoResourceError?) -> Unit)

Connects a chat session.

createChat
Link copied to clipboard
fun createChat(creationType: CreationType, onCompletion: (Either<Chat, SippoResourceError>) -> Unit)

Creates a new chat.

disablePushNotifications
Link copied to clipboard
fun disablePushNotifications(onCompletion: (SippoResourceError?) -> Unit)

Disables the Push Notifications for incoming messages. Disables notifications against XMPP server.

disconnect
Link copied to clipboard
fun disconnect(onCompletion: (SippoResourceError?) -> Unit)

Disconnects a chat session and disables the chat push notifications. This should be called on logout.

enablePushNotifications
Link copied to clipboard
fun enablePushNotifications(onCompletion: (SippoResourceError?) -> Unit)

Enables the Push Notifications for incoming messages. Enable notifications against XMPP server. It must be called after setPushToken or to have the dnd option disabled in order for it to work.

findChatById
Link copied to clipboard
fun findChatById(identifier: String): Chat?

Find a cached Chat that was identified by the stanzaId.

getAllChats
Link copied to clipboard
fun getAllChats(onCompletion: (Either<List<Chat>, SippoResourceError>) -> Unit)

Fetches both individual and group chats related to this user.

getGroupChats
Link copied to clipboard
fun getGroupChats(onCompletion: (Either<List<Chat>, SippoResourceError>) -> Unit)

Fetches all group chats related to this user.

getIndividualChats
Link copied to clipboard
fun getIndividualChats(onCompletion: (Either<List<Chat>, SippoResourceError>) -> Unit)

Fetches all individual chats related to this user.

joinGroupChats
Link copied to clipboard
fun joinGroupChats(onCompletion: (SippoResourceError?) -> Unit)

Joins all the group chats in the list of currentGroupChats.

removeChatClientListener
Link copied to clipboard
fun removeChatClientListener(listener: ChatClientListener)

Removes the specified listener.

removeGroupChatsListener
Link copied to clipboard
fun removeGroupChatsListener(listener: GroupChatsListener)

Removes the specified listener.

removeIndividualChatsListener
Link copied to clipboard
fun removeIndividualChatsListener(listener: IndividualChatsListener)

Removes the specified listener.

restore
Link copied to clipboard
fun restore(isDebugEnabled: Boolean = false, onCompletion: (SippoResourceError?) -> Unit)

Restores the active xmpp session.

suspend
Link copied to clipboard
fun suspend(onCompletion: (SippoResourceError?) -> Unit)

Suspends a chat session. This should be called when the app enters background in order to receive chat push notifications.