Chat - KaleyraVideo/VideoAndroidSDK GitHub Wiki

Get active chats

You can get the active chats with the following code

KaleyraVideo.conversation.chats.onEach {  }.launchIn(MainScope())

Place a chat

To start a chat please refer to the following snippet

KaleyraVideo.conversation.chat(currentActivity, userId = "userB"): Result<ChatUI> 

Place a group chat

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> 

Listen for chat events/errors

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())

Update displayed chat actions

Chat actions represents the call buttons that are enabled on the chat UI top app bar. To update or modify the call actions please refer to the following snippet:

KaleyraVideo.conversation.chatActions = ChatUI.Action.default

// or set chat actions manually 

KaleyraVideo.conversation.chatActions = setOf(
  ChatUI.Action.CreateCall(Call.PreferredType.audioVideo(), recordingType = Call.Recording.manual()),
  ChatUI.Action.CreateCall(Call.PreferredType.audioUpgradable(), recordingType = Call.Recording.automatic()),
  ChatUI.Action.CreateCall(Call.PreferredType.audioVideo(),  maxDuration = 120, recordingType = Call.Recording.disabled()),
)

// `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.

⚠️ **GitHub.com Fallback** ⚠️