Skip to main content

Typing indicator

The Nexconn SDK supports sending typing status in direct channels, allowing the UI to display "typing..." indicators.

tip
  • Typing indicators are supported in direct channels only.
  • The SDK rate-limits typing status to one message per 6 seconds per channel.

Send typing status

Use channel.sendTypingStatus() on a DirectChannel instance to notify the other user that the current user is typing.

kotlin
val channel = DirectChannel("userId")

editText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
if (s?.isNotEmpty() == true) {
channel.sendTypingStatus("RC:TxtMsg")
}
}

override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
})

Listen for typing status

Register a ChannelHandler using NCEngine.addChannelHandler() to receive typing status updates. The onTypingStatusChanged callback fires when the typing status of any participant in a channel changes.

kotlin
NCEngine.addChannelHandler("TYPING_HANDLER", object : ChannelHandler {
override fun onTypingStatusChanged(event: TypingStatusChangedEvent) {
event.userTypingStatus.forEach { info ->
Log.d("Typing", "${info.userId} is typing: ${info.typingContentType}")
}
}
})

Remove the listener

kotlin
NCEngine.removeChannelHandler("TYPING_HANDLER")

ChannelUserTypingStatusInfo properties

PropertyTypeDescription
userIdStringThe user ID of the participant who is typing.
typingContentTypeStringThe message content type being composed.
sentTimeLongThe timestamp (ms) when the typing status was sent.

Parameters

sendTypingStatus

ParameterTypeDescription
typingMessageTypeStringThe message type identifier being typed (see table below).

Common message type identifiers

Message typeIdentifier
Text messageRC:TxtMsg
Voice messageRC:VcMsg
Image messageRC:ImgMsg
File messageRC:FileMsg

Important notes

  • Typing indicators work in direct channels only.
  • The SDK enforces a 6-second rate limit internally.
  • Typing status is not persisted.
  • Stop sending typing status when the user clears the input field.