/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Copy a message

Copy link

A user can copy and send their own message in the same channel or to another channel. This works the same way for both open channels and group channels.

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 let the MessageCollection know that there is a new pending message. If the current user is connected, it adds the message to a message queue and returns the result of the message.

User message

Copy link
channel.copyUserMessage(MESSAGE_TO_COPY, toTargetChannel: TARGET_CHANNEL) { (userMessage, error) in
    guard error == nil else {
        // Handle error.
        return
    }

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

File message

Copy link
channel.copyFileMessage(MESSAGE_TO_COPY, toTargetChannel: TARGET_CHANNEL) { (fileMessage, error) in
    guard error == nil else {
        // Handle error.
        return
    }

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

Multiple file message

Copy link
channel.copyMultipleFilesMessage(MESSAGE_TO_COPY, toTargetChannel: TARGET_CHANNEL) { (multipleFilesMessage, error) in
    guard error == nil else {
        // Handle error.
        return
    }

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

List of parameters

Copy link
Parameter nameTypeDescription

message

UserMessage, FileMessage, MultipleFileMessage

Specifies a message to copy.

toTargetChannel

BaseChannel

Specifies a target channel to send a copied message to.

completionHandler

Closure

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