Forward messages

The message forwarding feature lets you resend published messages or conversations to:

  • Share relevant information - you can forward messages or threads with additional relevant context to other users, ensuring efficient knowledge sharing.

  • Collaborate and consult - forwarding messages helps in decision-making by involving those who may have valuable insights and can contribute to ongoing discussions or projects.

You can let users send a given message from one channel to another with forward() methods.

Both of them give the same output. The only difference is that you call a given method either directly on the message or the channel object. Depending on the object, these methods take different input parameters - you either have to specify the Message object you want to forward or the ID of the channel where you want to send the message.

Additional info in the forwarded message

Each forwarded message contains additional metadata: originalPublisher with the user ID of the person who originally published the message (to track its owner) and originalChannelId with the ID of the channel where the message was originally published.

Method signature

These methods take the following parameters:

  • forward() (on the Message object)

    message.forward(
    channelId: String,
    completion: ((Swift.Result<Timetoken, Error>) -> Void)?
    )
  • forward() (on the Channel object)

    channel.forward(
    message: MessageImpl,
    completion: ((Swift.Result<Timetoken, Error>) -> Void)? = nil
    )

Input

ParameterTypeRequired for MessageRequired in ChannelDefaultDescription
channelIdStringYesNon/aUnique identifier of the channel to which you want to forward the message. You can forward a message to the same channel on which it was published or to any other.
messageMessageImplNoYesn/aMessageImpl object that you want to forward to the selected channel.

Output

TypeDescription
TimetokenTimetoken of the forwarded message.

Basic usage

Forward the latest message from the support channel to the incident-management channel.

  • forward() (on the Message object)

    /// Assuming you have all necessary dependencies and a "chat" instance available
    /// Fetch the "support" channel
    chat?.getChannel(channelId: "support") { result in
    switch result {
    case let .success(channel):
    if let supportChannel = channel {
    print("Fetched support channel metadata with ID: \(supportChannel.id)")
    /// Get the latest message from the "support" channel's history
    supportChannel.getHistory(count: 1) { historyResult in
    switch historyResult {
    case let .success(response):
    if let latestMessage = response.messages.first {
    print("Latest message: \(latestMessage)")
    /// Forward the latest message to the "incident-management" channel
    latestMessage.forward(channelId: "incident-management") { forwardResult in
    show all 37 lines
  • forward() (on the Channel object)

    /// Assuming you have all necessary dependencies and a "chat" instance available
    /// Fetch the "support" channel
    chat?.getChannel(channelId: "support") { supportResult in
    switch supportResult {
    case let .success(supportChannel):
    if let supportChannel = supportChannel {
    print("Fetched support channel metadata with ID: \(supportChannel.id)")
    /// Get the latest message from the "support" channel's history
    supportChannel.getHistory(count: 1) { historyResult in
    switch historyResult {
    case let .success(response):
    if let latestMessage = response.messages.first {
    print("Latest message: \(latestMessage)")
    // Fetch the "incident-management" channel
    chat?.getChannel(channelId: "incident-management") { incidentResult in
    show all 49 lines
Last updated on