Skip to main content

Retrieve message history

The default Chat UI channel page implements historical message loading and display. For custom pages, use the nexconn message query APIs directly.

  • BaseChannel.createMessagesQuery(MessagesQueryParams): Load historical messages with pagination (automatically fills gaps from remote)
  • BaseChannel.createLocalMessagesByTimeQuery(LocalMessagesByTimeQueryParams): Query local historical messages by time cursor
  • BaseChannel instance.getMessagesAroundTime(GetMessagesAroundTimeParams, ...): Query messages around a specific message timestamp

Example

kotlin
val identifier = ChannelIdentifier(ChannelType.DIRECT, "user_001")
val query = BaseChannel.createMessagesQuery(
MessagesQueryParams(identifier).apply {
pageSize = 30
isAscending = false
}
)

query.loadNextPage { page, error ->
if (error == null) {
val messages = page?.data.orEmpty()
// Render historical messages
}
}