Skip to main content

Set message content

Update the MessageContent of a stored message.

warning

The SDK does not validate the MessageContent you provide. Ensure:

  • The MessageContent conforms to the Message definition.
  • The MessageContent type matches the objectName.

Incorrect values may cause corrupt data in the local database, affecting message display and search.

Set message content

There is no separate setMessageContent API. Use channel.updateMessage() with UpdateMessageParams to replace a stored message's content.

Parameters (UpdateMessageParams)

ParameterTypeDescription
messageIdStringThe server message ID.
contentMessageContentThe new message content (e.g., TextMessage, ImageMessage).
kotlin
val channel = DirectChannel("userId")

val newContent = TextMessage("Updated content")
val params = UpdateMessageParams(
messageId = message.messageId ?: "",
content = newContent
)

channel.updateMessage(params) { updatedMessage, error ->
if (error == null && updatedMessage != null) {
Log.d("SetMessageContent", "Message updated successfully")
} else {
Log.e("SetMessageContent", "Update failed: ${error?.code}")
}
}