Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4
A user can update any of their own text and file messages sent using UserMessageUpdateParams
and FileMessageUpdateParams
. An error is returned if a user attempts to update another user's messages. In addition, channel operators can update any messages sent in a channel.
val params = UserMessageUpdateParams().apply {
message = NEW_TEXT_MESSAGE
customType = NEW_CUSTOM_TYPE
data = NEW_DATA
}
// The MESSAGE_ID argument below indicates the unique message ID of a UserMessage object to update.
channel.updateUserMessage(MESSAGE_ID, params) { message, e ->
if (e != null) {
// Handle error.
}
// The message is successfully updated.
// Through the message parameter of the callback handler,
// you can check if the update operation has been performed correctly.
}
val params = FileMessageUpdateParams().apply {
customType = NEW_CUSTOM_TYPE
}
// The MESSAGE_ID argument below indicates the unique message ID of a FileMessage object to update.
channel.updateFileMessage(MESSAGE_ID, params) { message, e ->
if (e != null) {
// Handle error.
}
// The message is successfully updated.
// Through the message parameter of the callback handler,
// you can check if the update operation has been performed correctly.
}
If a message is updated, the onMessageUpdated()
method in the channel event handler will be invoked on all users' devices except the one that updated the message.
SendbirdChat.addChannelHandler(
UNIQUE_HANDLER_ID,
object : OpenChannelHandler() {
override fun onMessageUpdated(channel: BaseChannel, message: BaseMessage) {
// ...
}
// ...
}
)
SendbirdChat.addChannelHandler(
UNIQUE_HANDLER_ID,
object : GroupChannelHandler() {
override fun onMessageUpdated(channel: BaseChannel, message: BaseMessage) {
// ...
}
}
)