Package 

Class ChatClientExtensions

    • Method Detail

      • initGroupedQueryChannelsAsState

         final static StateFlow<QueryChannelsState> initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier, ChatEventHandlerFactory chatEventHandlerFactory, CoroutineScope coroutineScope)

        Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. Channels cached under the identifier's DB key are loaded optimistically so the UI can render immediately while the next queryGroupedChannels response populates the state via the listener.

        Only QueryChannelsIdentifier.Grouped is accepted — the standard offset-paginated path is served by queryChannelsAsState instead.

        Parameters:
        identifier - The grouped query's identifier whose state should be initialized.
        chatEventHandlerFactory - The factory used to create the ChatEventHandler that routes events into this grouped list.
        coroutineScope - The CoroutineScope used for executing the request.
      • initGroupedQueryChannelsAsState

         final static StateFlow<QueryChannelsState> initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier)

        Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. Channels cached under the identifier's DB key are loaded optimistically so the UI can render immediately while the next queryGroupedChannels response populates the state via the listener.

        Only QueryChannelsIdentifier.Grouped is accepted — the standard offset-paginated path is served by queryChannelsAsState instead.

        Parameters:
        identifier - The grouped query's identifier whose state should be initialized.
      • watchChannelAsState

         final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit, CoroutineScope coroutineScope)

        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.

        Parameters:
        cid - The full channel id, i.e.
        messageLimit - The number of messages that will be initially loaded.
        coroutineScope - The CoroutineScope used for executing the request.
      • watchChannelAsState

         final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit)

        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.

        Parameters:
        cid - The full channel id, i.e.
        messageLimit - The number of messages that will be initially loaded.
      • watchChannelAsState

         final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit, String aroundMessageId, CoroutineScope coroutineScope)

        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.

        Parameters:
        aroundMessageId - When non-null, the initial watch uses AROUND_ID pagination to load messages around this ID.
      • watchChannelAsState

         final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit, String aroundMessageId)

        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.

        Parameters:
        aroundMessageId - When non-null, the initial watch uses AROUND_ID pagination to load messages around this ID.
      • getRepliesAsState

         final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer, CoroutineScope coroutineScope)

        Same class of ChatClient.getReplies, but provides the result as ThreadState

        Parameters:
        messageId - The ID of the original message the replies were made to.
        messageLimit - The number of messages that will be initially loaded.
        olderToNewer - The flag that determines the order of the messages.
        coroutineScope - The CoroutineScope used for executing the request.
      • getRepliesAsState

         final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)

        Same class of ChatClient.getReplies, but provides the result as ThreadState

        Parameters:
        messageId - The ID of the original message the replies were made to.
        messageLimit - The number of messages that will be initially loaded.
        olderToNewer - The flag that determines the order of the messages.
      • awaitRepliesAsState

         final static ThreadState awaitRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)

        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.

        Parameters:
        messageId - The ID of the original message the replies were made to.
        messageLimit - The number of messages that will be initially loaded.
        olderToNewer - The flag that determines the order of the messages.
      • setMessageForReply

         final static Call<Unit> setMessageForReply(ChatClient $self, String cid, Message message)

        Set the reply state for the channel.

        Parameters:
        cid - CID of the channel where reply state is being set.
        message - The message we want reply to.
      • downloadAttachment

         final static Call<Unit> downloadAttachment(ChatClient $self, Context context, Attachment attachment)

        Downloads the selected attachment to the "Download" folder in the public external storage directory.

        If a CDN is configured on this ChatClient, the download URL and headers are transformed via CDN.imageRequest (for images) or CDN.fileRequest (for other files) before the download is enqueued.

        Parameters:
        context - The context used to access the DownloadManager.
        attachment - The attachment to download.
      • loadOlderMessages

         final static Call<Channel> loadOlderMessages(ChatClient $self, String cid, Integer messageLimit)

        Loads older messages for the channel.

        Parameters:
        cid - The full channel id i.e.
        messageLimit - How many new messages to load.
      • loadMessagesAroundId

         final static Call<Channel> loadMessagesAroundId(ChatClient $self, String cid, String messageId)

        Loads messages around the given message id.

        Parameters:
        cid - The full channel id i.e.
        messageId - The id of the message around which we want to load messages.
      • cancelEphemeralMessage

         final static Call<Boolean> cancelEphemeralMessage(ChatClient $self, Message message)

        Cancels the message of "ephemeral" type. Removes the message from local storage and state.

        Parameters:
        message - The ephemeral message to cancel.
      • getMessageUsingCache

         final static Call<Message> getMessageUsingCache(ChatClient $self, String messageId)

        Attempts to fetch the message from offline cache before making an API call.

        Parameters:
        messageId - The id of the message we are fetching.
      • loadMessageById

         final static Call<Message> loadMessageById(ChatClient $self, String cid, String messageId)

        Loads message for a given message id and channel id.

        Parameters:
        cid - The full channel id i.
        messageId - The id of the message.
      • loadNewestMessages

         final static Call<Channel> loadNewestMessages(ChatClient $self, String cid, Integer messageLimit, Boolean userPresence)

        Loads the newest messages of a channel.

        Parameters:
        cid - The full channel id i.
        messageLimit - The number of messages to be loaded.
        userPresence - Flag to determine if the SDK is going to receive UserPresenceChanged events.