/ SDKs / Unreal
SDKs
Chat SDKs Unreal v3
Chat SDKs Unreal
Chat SDKs
Unreal
Version 3

Load messages by timestamp or message ID

Copy link

You can retrieve a set number of previous or next messages on referenced to a specific timestamp in a channel. You can also retrieve messages by using a message ID.


By timestamp

Copy link

Use the GetMessagesByTimestamp() method to retrieve a set number of previous and next messages on both sides of a specific timestamp.

channel->GetMessagesByTimestamp(TIMESTAMP, PREVIOUS_LIMIT, NEXT_LIMIT, REVERSE, SBDMessageTypeFilter::All, CUSTOM_TYPE, [](const vector<SBDBaseMessage*>& messages, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // A list of previous or next messages referenced to a specific timestamp is successfully retrieved.
    // Through the messages parameter of the handler callback function,
    // 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 arguments

Copy link
ArgumentTypeDescription

TIMESTAMP

int64_t

Specifies the timestamp to be the reference point of a retrieval, in Unix milliseconds.

PREV_LIMIT

int64_t

Specifies the number of previously sent messages to retrieve before the specified message timestamp. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the earliest message.

NEXT_LIMIT

int64_t

Specifies the number of sent messages to retrieve after the specified message timestamp. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the latest message.

REVERSE

bool

Determines whether to sort the retrieved messages in reverse chronological order. If set to true, messages appear in reverse chronological order where the newest comes first and the oldest last. (Default: false)

MESSAGE_TYPE

enum

Specifies a message type to retrieve. Acceptable values are SBDMessageTypeFilter.All, SBDMessageTypeFilter.User, SBDMessageTypeFilter.File, and SBDMessageTypeFilter.Admin. If not specified, the scope of retrieval is set to all messages.

CUSTOM_TYPE

std::wstring

Specifies the custom type of messages to retrieve. If not specified, all messages are retrieved.


By message ID

Copy link

You can also retrieve a set number of previous and next messages on both sides of a specific message ID in a channel, using the GetMessagesByMessageId() method.

channel->GetMessagesByMessageId(MESSAGE_ID, PREVIOUS_LIMIT, NEXT_LIMIT, REVERSE, SBDMessageTypeFilter::All, CUSTOM_TYPE, [](const vector<SBDBaseMessage*>& messages, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // A list of previous or next messages referenced to a specific message ID is successfully retrieved.
    // Through the messages parameter of the handler callback function,
    // 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 arguments

Copy link
ArgumentTypeDescription

MESSAGE_ID

int64_t

Specifies the unique ID of the message to be the reference point of a retrieval.

PREV_LIMIT

int64_t

Specifies the number of previously sent messages to retrieve before the specified message timestamp. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the earliest message.

NEXT_LIMIT

int64_t

Specifies the number of sent messages to retrieve after the specified message timestamp. Note that the actual number of results may be larger than the set value when there are multiple messages with the same timestamp as the latest message.

REVERSE

bool

Determines whether to sort the retrieved messages in reverse chronological order. If set to true, messages appear in reverse chronological order where the newest comes first and the oldest last. (Default: false)

MESSAGE_TYPE

enum

Specifies a message type to retrieve. Acceptable values are SBDMessageTypeFilter.All, SBDMessageTypeFilter.User, SBDMessageTypeFilter.File, and SBDMessageTypeFilter.Admin. If not specified, the scope of retrieval is set to all messages.

CUSTOM_TYPE

std::wstring

Specifies the custom type of messages to retrieve. If not specified, all messages are retrieved.