ChatClient
The ChatClient is the main entry point for all low-level operations on chat
Types
Builder to initialize the singleton ChatClient instance and configure its parameters.
Properties
GlobalState instance that contains information about the current user, unreads, etc.
Retrieves a Flow holding the GlobalState object, which emits only if the user is connected, and the ChatClient is in InitializationState.COMPLETE state.
StateRegistry instance that contains all state objects exposed in offline plugin. The instance is being initialized after connecting the user!
Functions
Accepts the invitation to join a channel.
Adds members to a given channel.
Get the current settings of the app. Check AppSettings.
Archive the channel for the current user.
Returns thread replies in the form of ThreadState, however, unlike getRepliesAsState it will return it only after the API call made to get replies has ended. Thread state will be returned regardless if the API call has succeeded or failed, the only difference is in how up to date the replies in the thread state are.
Block a user by ID.
Cancels the message of "ephemeral" type. Removes the message from local storage and state.
Cast an answer in a poll.
Cast a vote for a poll in a message.
Returns a ChannelClient for given cid.
Returns a ChannelClient for given type and id.
Clears all cache and temporary files created by the Stream Chat SDK.
Clear local data stored on the device from the current user.
Close a poll in a message.
Initializes ChatClient for a specific user. The tokenProvider implementation is used for the initial token, and it's also invoked whenever the user's token has expired, to fetch a new token.
Initializes ChatClient for a specific user using the given user token. Check ChatClient.connectUser with TokenProvider parameter for advanced use cases.
Checks if there are currently stored user credentials in the local storage.
Creates the channel. You can either create an id-based channel by passing not blank channelId or member-based (distinct) channel by leaving channelId empty. Use CreateChannelParams.members list to create a channel together with members. Make sure the list is not empty in case of creating member-based channel! Extra channel's information, for example name, can be passed in the CreateChannelParams.extraData map.
Creates the channel. You can either create an id-based channel by passing not blank channelId or member-based (distinct) channel by leaving channelId empty. Use memberIds list to create a channel together with members. Make sure the list is not empty in case of creating member-based channel! Extra channel's information, for example name, can be passed in the extraData map.
Create a new draft message. The call will be retried accordingly to retryPolicy.
Create a new option for a poll.
Creates a reminder for a message.
Deletes the channel specified by the channelType and channelId.
Delete a draft message. The call will be retried accordingly to retryPolicy.
Deletes a file not related to any channel.
Deletes the file represented by url from the given channel.
Deletes an image not related to any channel.
Deletes the image represented by url from the given channel.
Deletes a message.
Deletes a message for the current user only, making it invisible for them while keeping it visible for others.
Deletes a poll.
Delete an option from a poll.
Deletes a reminder for a message.
Disables slow mode for the channel.
Disconnect the current user, stop all observers and clear user data. This method should only be used whenever the user logouts from the main app. You shouldn't call this method, if the user will continue using the Chat in the future.
Dismiss notifications from a given channelType and channelId. Be sure to initialize ChatClient before calling this method!
Downloads the selected attachment to the "Download" folder in the public external storage directory.
Downloads the given file which can be fetched through the response body.
Edits an existing message, uploading any new attachments through the standard AttachmentsSender / UploadAttachmentsAndroidWorker pipeline before updating the message on the server.
Enables slow mode for the channel. When slow mode is enabled, users can only send a message every cooldownTimeInSeconds time interval. The cooldownTimeInSeconds is specified in seconds, and should be between 1-MAX_COOLDOWN_TIME_SECONDS.
Enriches the given URL with Open Graph data.
Fetches the current user. Works only if the user was previously set and the WS connections is closed.
Default filter to include FilterObject in a channel by its cid
Returns application settings from the server or the default ones as a fallback.
Gets the channel from the server based on cid.
Gets the channel from the server based on channelType and channelId.
Retrieves the current user token (or null if it doesn't exist).
Retrieves the file attachments from the given channel.
Retrieves the image attachments from the given channel.
Fetches a single message from the backend.
Attempts to fetch the message from offline cache before making an API call.
Fetches a single pending message from the backend.
Returns a list of messages pinned in the channel. You can sort the list by specifying sort parameter. Keep in mind that for now we only support sorting by Message.pinnedAt. The list can be paginated in a few different ways using limit and pagination.
Get a poll by id.
Retrieves the reactions on a given message.
Same class of ChatClient.getReplies, but provides the result as ThreadState
Returns all events that happened for a list of channels since last sync (while the user was not connected to the web-socket).
Returns all events that happened for a list of channels since last sync (while the user was not connected to the web socket). lastSyncAt is in yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z' format. Use this version of getSyncHistory when high precision is necessary.
Get a thread by message id.
Gets the unread counts for the current user.
Hides the specified channel with side effects.
Inherits the UserScope and provides its Job as an anchor for children.
Checks if the chat socket is connected.
Loads message for a given message id and channel id.
Loads messages around the given message id.
Loads the newest messages of a channel.
Loads older messages for the channel.
Marks all the channel as read.
Request to mark the message with the given id as delivered if:
Marks the given message as read.
Marks a given thread as read.
Marks a thread as unread.
Marks all messages in the channel as unread that were created after the specified timestamp.
Marks the specified channel as unread.
Mutes a channel for the current user. Messages added to the channel will not trigger push notifications, and will not change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set an expiration time. Triggers notification.channel_mutes_updated event.
Mutes a user. Messages from muted users will not trigger push notifications. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set a mute timeout. Triggers notification.mutes_updated event.
Partially updates specific Thread fields retaining the fields which were set previously.
Pin the channel for the current user.
Pins the message.
Queries the active locations (non-expired) shared by the current user.
Queries the banned users matching the provided filters.
Return na list of blocked users.
Gets the channel from the server based on channelType, channelId and parameters from QueryChannelRequest. The call requires active socket connection if QueryChannelRequest.watch or QueryChannelRequest.presence is enabled, and will be automatically postponed and retried until the connection is established or the maximum number of attempts is reached.
Gets the channels from the server based on parameters from QueryChannelsRequest. The call requires active socket connection if QueryChannelsRequest.watch or QueryChannelsRequest.presence is enabled, and will be automatically postponed and retried until the connection is established or the maximum number of attempts is reached.
Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. The QueryChannelsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
Gets the channels without running any side effects.
Query draft messages for the current user.
Query members and apply side effects if there are any.
Query polls with optional filtering, pagination, and sorting.
Query votes for a specific poll with optional filtering, pagination, and sorting.
Queries reactions for a given message.
Queries the message reminders for the current user matching the provided filters.
Query threads matching query request.
Performs ChatClient.queryThreads under the hood and returns QueryThreadsState. The QueryThreadsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
Query users matching query request.
Reconnects the socket. Works only if the user was previously set and the WS connections is closed.
Rejects the invitation to join the channel.
Remove a vote for a poll in a message.
Removes a shadow ban from a user in a given channel.
Search messages across channels. There are two ways to paginate through search results:
Uploads a file for the given channel. Progress can be accessed via callback.
Sends selected giphy message to the channel specified by Message.cid. The call will be retried accordingly to retryPolicy.
Uploads an image for the given channel. Progress can be accessed via callback.
Sends the message to the given channel. If isRetrying is set to true, the message may not be prepared again.
Send a message with a poll to the given channel.
Sends the reaction. Use enforceUnique parameter to specify whether the reaction should replace other reactions added by the current user. cid parameter is being used in side effect functions executed by plugins. You can skip it if plugins are not being used.
Sets the push notification preference level for a specific channel.
Set the reply state for the channel.
Sets the push notification preference level for the current user. This controls which messages will trigger push notifications for the user across all channels.
Shows the specified channel (if previously hidden).
Performs Giphy shuffle operation in the channel specified by Message.cid. Returns new "ephemeral" message with new giphy url. The call will be retried accordingly to retryPolicy.
Temporarily disables push notifications for a specific channel until the specified date.
Temporarily disables push notifications for the current user until the specified date. This is useful for implementing "Do Not Disturb" functionality where users can snooze notifications for a specific period of time.
Stops the live location sharing for a message.
Sends a EventType.TYPING_STOP event to the backend.
Stops watching the channel which means you won't receive more events for the channel. The call requires active socket connection and will be automatically postponed and retried until the connection is established.
Subscribes to the specific eventTypes of the client.
Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner.
Subscribes to client events of type T.
Subscribes to client events of type T, in the lifecycle of lifecycleOwner.
Subscribes to the specific eventTypes of the client.
Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner.
Subscribes for the next event with the given eventType.
Subscribes for the next client event of type T.
Changes the user. Disconnects the current user and connects to a new one. The tokenProvider implementation is used for the initial token, and it's also invoked whenever the user's token has expired, to fetch a new token.
Changes the user. Disconnects the current user and connects to a new one. The tokenProvider implementation is used for the initial token, and it's also invoked whenever the user's token has expired, to fetch a new token.
Removes all of the messages of the channel but doesn't affect the channel data or members.
Unarchive the channel for the current user.
Unblock a user by ID.
Un-flags a previously flagged message.
Un-flags a previously flagged user.
Unmutes a channel for the current user. Triggers notification.channel_mutes_updated event.
Unmutes a previously muted user. Triggers notification.mutes_updated event.
Unpin the channel for the current user.
Unpins the message that was previously pinned
Updates the message in the API and calls the plugins that handle this request. OfflinePlugin can be used here to store the updated message locally.
Update a poll.
Update an existing option in a poll.
Updates an existing reminder for a message.
Updates a single user.
Updates multiple users in a single request.
Uploads a file not related to any channel. Progress can be accessed via progressCallback.
Uploads an image not related to any channel. Progress can be accessed via progressCallback.
Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. The ChannelState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
Same as watchChannelAsState but loads messages around the given aroundMessageId in the initial request. Use this when opening a channel with focus on a specific message (e.g. deep-link) to avoid a race between the initial watch and a separate loadAround call.