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

List replies in a message thread

Copy link

You can retrieve replies to a message by identifying the parent message like the following. First, create a ThreadedMessageListParams object and set properties related to the thread where the target replies belong to.

// Create a ThreadedMessageListParams object.
let params = ThreadedMessageListParams()
params.previousResultSize = PREVIOUS_RESULT_SIZE
params.nextResultSize = NEXT_RESULT_SIZE
params.isInclusive = IS_INCLUSIVE
params.reverse = REVERSE
params.includeParentMessageInfo = INCLUDE_PARENT_MESSAGE_INFO

ThreadedMessageListParams

Copy link
Property nameTypeDescription

previousResultSize

Int

Specifies the number of messages to retrieve that were sent before the specified timestamp.

nextResultSize

Int

Specifies the number of messages to retrieve that were sent after the specified timestamp.

isInclusive

Bool

Determines whether to include the messages with the matching timestamp in the result.

reverse

Bool

Determines whether to sort the retrieved messages in reverse order. If set to false, the result is displayed in ascending order.

includeParentMessageInfo

Bool

Determines whether to include information about the parent message in the result.

Using the timestamp of the parent message, you can retrieve the parent message with its replies by passing the ThreadedMessageListParams object to the getThreadedMessages(timestamp:params:completionHandler:) method as an argument.

// Pass the params to the parameter in the getThreadedMessages(timestamp:params:completionHandler:) method.
parentMessage.getThreadedMessages(timestamp: TIMESTAMP, params: params) { (parentMessage, threadedReplies, error) in
    guard error == nil else {
        // Handle error.
        return 
    }

    // A list of replies of the specified parent message timestamp is successfully retrieved.
    // Through the threadedReplies parameter of the callback method,
    // you can access and display the data of each message
    // from the result list that the Sendbird server has passed to the callback method.
}

List of parameters

Copy link
Parameter nameTypeDescription

timestamp

Int64

Specifies the timestamp to be the reference point of message retrieval in Unix milliseconds format.