/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Copy a message

Copy link

A user can copy and send their own message in the same channel or to another channel.

For those who are using messageCollection, copying a message will take place as follows. First, pass a target message to copy and the target channel where the message is located to one of the copyUserMessage(), copyFileMessage(), or copyMultipleFilesMessage() methods. Then the SDK creates a pending message using the target message content and notifies the MessageCollection that there is a new pending message. If the current user is connected, the SDK adds the message to a message queue and returns the result of the message.

User message

Copy link
KotlinKTX
channel.copyUserMessage(TARGET_CHANNEL, MESSAGE_TO_COPY) { message, e ->
    if (e != null) {
        // Handle error.
    }

    // The message is successfully copied to the target channel.
}

File message

Copy link
KotlinKTX
channel.copyFileMessage(TARGET_CHANNEL, MESSAGE_TO_COPY) { message, e ->
    if (e != null) {
        // Handle error.
    }

    // The message is successfully copied to the target channel.
}

Multiple file message

Copy link
KotlinKTX
channel.copyMultipleFilesMessage(TARGET_CHANNEL, MESSAGE_TO_COPY) { message, e ->
    if (e != null) {
        // Handle error.
    }
    // The message is successfully copied to the target channel.
}

List of parameters

Copy link
Parameter nameTypeDescription

userMessage

BaseMessage

Specifies a user message to copy.

fileMessage

BaseMessage

Specifies a file message to copy.

multipleFilesMessage

BaseMessage

Specifies a multiple file message to copy.

targetChannel

BaseChannel

Specifies a target channel to send a copied message to.

handler

Interface

Specifies the callback handler to receive the response from the Sendbird server for a message copy request.