Chat - KaleyraVideo/VideoAndroidSDK GitHub Wiki
You can get the active chats with the following code
KaleyraVideo.conversation.chats.onEach { }.launchIn(MainScope())
To start a chat please refer to the following snippet
KaleyraVideo.conversation.chat(currentActivity, userId = "userB"): Result<ChatUI>
To start a group chat please refer to the following snippet
// this will create the unique chat between logged user, "userB" and "userC"
KaleyraVideo.conversation.chat(currentActivity, userIds = listOf("userB", "userC")): Result<ChatUI>
// this will always create a new group chat between logged user, "userB" and "userC" with the
// group chat friendly name set as "soccer team!"
KaleyraVideo.conversation.chat(currentActivity, userIds = listOf("userB", "userC"), friendlyName = "soccer team!"): Result<ChatUI>
To observe a chat that has started, has ended or has ended with an error is it necessary to listen for the chat state flow.
chat.state.onEach { chatState ->
Log.d("CHAT STATE", "$chatState")
}.launchIn(MainScope())
Chat actions represents the call buttons that are enabled on the chat UI top app bar. By default audio call button and audio upgradable to video call button will be placed on the chat UI. To update or modify the chat call actions please refer to the following snippet:
KaleyraVideo.conversation.chats.onEach { chats ->
chats.forEach {
it.buttonsProvider = { defaultButtons ->
// return the default buttons
// or update by providing a new set of chat buttons as shown below:
setOf(
ChatUI.Button.Call(callType = Call.Type.audioVideo(), maxDuration = 90, recordingType = Call.Recording.Type.Automatic),
ChatUI.Button.Call(callType = Call.Type.audioUpgradable(), maxDuration = 90, recordingType = Call.Recording.Type.Automatic),
ChatUI.Button.Call(callType = Call.Type.audioOnly(), maxDuration = 90, recordingType = Call.Recording.Type.Automatic)
)
}
}
}.launchIn(MainScope())
// `maxDuration` optional parameter represents the maximum duration of the call in seconds, if not set it will have indeterminate duration
// `recordingType` optional parameter represents the recording type of the call, if not set call will not be recorded
Please follow the ChatUI.Action documentation to get all the available actions.