/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

List pinned messages

Copy link

To retrieve all the pinned messages in a group channel, use PinnedMessageListQuery.

First, create a PinnedMessageListQueryParams object. This query params has properties such as channelUrl, channelType, and messagePayloadParams. Especially messagePayloadParams contains booleans that determine which additional information to include in the pinned message payloads. For example, if a pinned message is a child message in a message thread, set includeParentMessageInfo to true in the query to show its parent message information in the message payload.

Once the query params is set, pass it to the createPinnedMessageListQuery() method to create a query. This query retrieves a list of pinned messages with relevant information specified in the messagePayloadParams instance.

// Create a params for PinnedMessageListQuery.
val params = PinnedMessageListQueryParams(
    channelType = channel.channelType,
    channelUrl = channel.url,
).apply {
    limit = 50
    // Configure which information to include in the message payloads.
    messagePayloadParams = MessagePayloadParams().apply {
        includeMetaArray = true
        includeReactions = true
        includeParentMessageInfo = true
        includeThreadInfo = true
    }
    includePollDetails = true
}

val query = SendbirdChat.createPinnedMessageListQuery(params)

// Retrieve pinned messages.
query.next { pinnedMessages, e ->
    if (e != null) {
        // Handler error
    }
}