StatePluginConfig
Provides a configuration for io.getstream.chat.android.state.plugin.internal.StatePlugin.
Parameters
Controls whether the SDK performs background synchronization when push notifications are received. When enabled (default: true), the SDK automatically syncs messages in the background when a push notification arrives, ensuring the local state/database stays up-to-date even when the app is in the background. This is particularly useful for displaying accurate notification content and maintaining offline state consistency. Disable this if you want to reduce background processing.
Controls whether the SDK subscribes to and processes user presence events (online/offline status, last active time). When enabled (default: true), the SDK receives real-time updates about user presence changes and updates the user objects in channels, members, and watchers accordingly. This affects both WebSocket event subscriptions and the presence parameter in API requests. Disabling this can reduce network traffic and processing overhead if your application doesn't need to display user online/offline status.
Specifies if local data is updated with subscribing to web-socket events after reconnection. When turning this off, it is up for SDK user to observe web-socket connection state for reconnection and syncing data by calling, for example ChatClient.queryChannels, or the StatePlugin methods such as ChatClient.queryChannelsAsState / ChatClient.watchChannelAsState. Note that these calls fetch the latest state and also subscribe to web-socket events if the query's watch is set to true.
Web-socket connection status can be monitored by observing the ClientState.connectionState flow, exposed from the ChatClient.clientState:
client.clientState.connectionState.collectLatest { state ->
when (state) {
is ConnectionState.Connected -> {
// Data can be updated and watching can be resumed
}
else -> {}
}
}The maximum age threshold for pending local operations (channels, messages, reactions) before they are considered too old to retry and are discarded. Default is 12 hours. When the SDK attempts to retry failed operations (e.g., sending a message, creating a channel, adding a reaction) upon reconnection, it checks if the operation's timestamp (createdLocallyAt, updatedLocallyAt, deletedAt, or createdAt) exceeds this threshold. If it does, the operation is removed from the local database instead of being retried, preventing the SDK from attempting to sync stale operations that are no longer relevant.
A function that provides the current time in milliseconds since epoch (Unix timestamp). Defaults to System.currentTimeMillis. This is used throughout the state plugin for time-based operations such as:
Determining if pinned messages have expired (based on
pinExpirestimestamp)Calculating sync thresholds and time differences
Timestamping state updates This parameter primarily exists for testing purposes, allowing tests to inject a controlled time source, but can also be used in production if you need custom time handling (e.g., using a synchronized server time).
Configuration that controls the maximum number of messages kept in memory for different channel types. This helps manage memory usage in channels with large message histories. When the number of messages exceeds the configured limit (plus a buffer), older messages are automatically trimmed from the in-memory state. By default, no limits are applied, meaning all messages are kept in memory. See MessageLimitConfig and ChannelMessageLimit for configuration details.