Quoted messages

Quoted Messages feature lets users reference previous messages within a conversation. By quoting a message, users can provide additional context or relevant details, ensuring coherence even when referencing older messages.

Quote message

There is no dedicated method for quoting messages. You must use sendText() - the same method you use for sending text messages - and attach the required quoted message information.

Method signature

Head over to the sendText() method section for details.

Basic Usage

Sample code

The code samples in Swift Chat SDK focus on asynchronous code execution.

You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.

Quote the message with the 16200000000000001 timetoken.

// Example timetoken
let timetoken: Timetoken = 16200000000000001
// Assuming you have a reference of type "ChatImpl" named "chat"
Task {
if let channel = try await chat.getChannel(channelId: "support") {
if let message = try await channel.getMessage(timetoken: timetoken) {
try await channel.sendText(
text: "Quoting the message with timetoken \(timetoken)",
quotedMessage: message
)
} else {
debugPrint("Message with the specified timetoken not found")
}
} else {
debugPrint("Channel not found")
show all 17 lines

Get quoted message

You can access the quotedMessage property of the Message object to list the original quoted message.

Basic usage

Sample code

The code samples in Swift Chat SDK focus on asynchronous code execution.

You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.

Return a quote from the message with the 16200000000000001 timetoken.

// Example timetoken
let timetoken: Timetoken = 16200000000000001
// Assuming you have a reference of type "ChatImpl" named "chat"
Task {
if let channel = try await chat.getChannel(channelId: "support") {
if let message = try await channel.getMessage(timetoken: timetoken) {
// The `message.qutoedMessage` property stores only values for the timetoken, text, and user identifier parameters.
// If you want to return the full quoted message object, use the `getMessage(timetoken:)` method
// and pass the `timetoken` property from the `QuotedMessage` value
debugPrint("Quoted message: \(String(describing: message.quotedMessage))")
} else {
debugPrint("Message with the specified timetoken not found")
}
} else {
debugPrint("Channel not found")
show all 17 lines

quotedMessage returns only values for the timetoken, text, and userId parameters. If you want to return the full quoted Message object, use the getMessage() method and the timetoken from the quote that you can extract from the quotedMessage parameter added to the published message.

Last updated on