Get message history
Retrieve message history from a community subchannel using BaseChannel.createMessagesQuery().
Get local or remote messages
Dart
final query = BaseChannel.createMessagesQuery(MessagesQueryParams(
channel: ChannelIdentifier(
channelType: ChannelType.community,
channelId: '<community-id>',
subChannelId: '<subchannel-id>',
),
policy: MessageOperationPolicy.localRemote,
pageSize: 20,
));
await query.loadNextPage((result, error) {
if (error == null) {
print('Loaded ${result?.data.length} messages');
print('Total matched: ${result?.totalCount}');
}
});
MessagesQueryParams
| Parameter | Type | Default | Description |
|---|---|---|---|
channel | ChannelIdentifier | Required | Community channel identifier. Set subChannelId to the target subchannel. |
order | TimeOrder | TimeOrder.before | Direction for paging through history. |
policy | MessageOperationPolicy | local | Query source: local, remote, or localRemote. |
messageType | MessageType | unknown | Message type filter. unknown means all types. |
pageSize | int | 20 | Messages per page. |
PageResult<Message>
| Property | Type | Description |
|---|---|---|
data | List<Message> | Messages returned in the current page. |
totalCount | int | Total number of messages matched by the query. |