Chat history
Load past messages for a conversation thread with fetchChatHistory. On WebSocket clients, the response arrives via onMessage — not as the return value of the method call.
When to fetch
User opens a thread
fetchChatHistory for the peer ID(s)
App returns from background
Refetch or merge with live messages since last seen
After reconnect
Refetch to fill gaps from offline period
API contract
senderId
The requesting user (must match connected userId)
receiverIds
Array of peer user IDs defining the thread
await notifier.fetchChatHistory({
senderId: "user-alice",
receiverIds: ["user-bob"],
});
// Response delivered to onMessageHandling the response
History payloads arrive in onMessage. Shape is app-dependent but commonly includes a messages array:
Distinguish history responses from live messages by checking for the messages array or a metadata hint your app recognizes.
HTTP transport note
With transport: "http", fetchChatHistory may return the response directly from the async call instead of routing through onMessage. For chat UIs, prefer ws for unified live + history handling.
Language guides
JavaScript / TypeScript
Dart / Flutter
Related topics
Last updated