Class ChatClient
-
- All Implemented Interfaces:
public final class ChatClientThe ChatClient is the main entry point for all low-level operations on chat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classChatClient.BuilderBuilder to initialize the singleton ChatClient instance and configure its parameters.
public abstract classChatClient.ChatClientBuilderpublic classChatClient.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static LongRESOLVE_DEPENDENCY_TIMEOUTpublic final static QuerySorter<Member>DEFAULT_SORTprivate final ClientStateclientStateprivate final RepositoryFacaderepositoryFacadeprivate List<Plugin>pluginsprivate ChannelStateLogicProviderlogicRegistryprivate final ChatClientConfigconfigprivate final List<PluginFactory>pluginFactoriesprivate final AudioPlayeraudioPlayerpublic final static ChatClient.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final ClientStategetClientState()final RepositoryFacadegetRepositoryFacade()final List<Plugin>getPlugins()The list of plugins added once user is connected. final UnitsetPlugins(List<Plugin> plugins)The list of plugins added once user is connected. final ChannelStateLogicProvidergetLogicRegistry()final UnitsetLogicRegistry(ChannelStateLogicProvider logicRegistry)final ChatClientConfiggetConfig()final List<PluginFactory>getPluginFactories()final AudioPlayergetAudioPlayer()final CoroutineScopeinheritScope(Function1<Job, CoroutineContext> block)Inherits the UserScope and provides its Job as an anchor for children. final <DR extends DependencyResolver, T extends Any> TresolveDependency()Resolves dependency T within the provided plugin DR. final InitializationStateawaitInitializationState(Long timeoutMilliseconds)final Call<AppSettings>appSettings()Get the current settings of the app. final Call<ConnectionData>connectUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds)Initializes ChatClient for a specific user. final Call<ConnectionData>connectUser(User user, TokenProvider tokenProvider)Initializes ChatClient for a specific user. final Call<ConnectionData>connectUser(User user, String token, Long timeoutMilliseconds)Initializes ChatClient for a specific user using the given user token. final Call<ConnectionData>connectUser(User user, String token)Initializes ChatClient for a specific user using the given user token. final Call<ConnectionData>switchUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds, Function0<Unit> onDisconnectionComplete)Changes the user. final Call<ConnectionData>switchUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds)Changes the user. final Call<ConnectionData>switchUser(User user, TokenProvider tokenProvider)Changes the user. final Call<ConnectionData>switchUser(User user, String token, Long timeoutMilliseconds, Function0<Unit> onDisconnectionComplete)Changes the user. final Call<ConnectionData>switchUser(User user, String token, Long timeoutMilliseconds)Changes the user. final Call<ConnectionData>switchUser(User user, String token)Changes the user. final BooleancontainsStoredCredentials()Checks if there are currently stored user credentials in the local storage. final Call<ConnectionData>connectAnonymousUser(Long timeoutMilliseconds)final Call<ConnectionData>connectAnonymousUser()final Call<ConnectionData>connectGuestUser(String userId, String username, Long timeoutMilliseconds)final Call<ConnectionData>connectGuestUser(String userId, String username)final Call<GuestUser>getGuestToken(String userId, String userName)final Call<List<Member>>queryMembers(String channelType, String channelId, Integer offset, Integer limit, FilterObject filter, QuerySorter<Member> sort, List<Member> members)Query members and apply side effects if there are any. final Call<UploadedFile>sendFile(String channelType, String channelId, File file, ProgressCallback callback)Uploads a file for the given channel. final Call<UploadedFile>sendFile(String channelType, String channelId, File file)Uploads a file for the given channel. final Call<UploadedFile>sendImage(String channelType, String channelId, File file, ProgressCallback callback)Uploads an image for the given channel. final Call<UploadedFile>sendImage(String channelType, String channelId, File file)Uploads an image for the given channel. final Call<Unit>deleteFile(String channelType, String channelId, String url)Deletes the file represented by url from the given channel. final Call<Unit>deleteImage(String channelType, String channelId, String url)Deletes the image represented by url from the given channel. final Call<List<Reaction>>getReactions(String messageId, Integer offset, Integer limit)Retrieves the reactions on a given message. final Call<Message>deleteReaction(String messageId, String reactionType, String cid)Deletes the reaction associated with the message with the given message id. final Call<Reaction>sendReaction(Reaction reaction, Boolean enforceUnique, String cid)Sends the reaction. final Call<Reaction>sendReaction(Reaction reaction, Boolean enforceUnique)Sends the reaction. final Call<Unit>disconnectSocket()final Call<User>fetchCurrentUser()Fetches the current user. final Call<Unit>reconnectSocket()Reconnects the socket. final UnitaddSocketListener(SocketListener listener)final UnitremoveSocketListener(SocketListener listener)final Disposablesubscribe(ChatEventListener<ChatEvent> listener)final DisposablesubscribeFor(String eventTypes, ChatEventListener<ChatEvent> listener)Subscribes to the specific eventTypes of the client. final DisposablesubscribeFor(LifecycleOwner lifecycleOwner, String eventTypes, ChatEventListener<ChatEvent> listener)Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner. final DisposablesubscribeFor(Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)Subscribes to the specific eventTypes of the client. final DisposablesubscribeFor(LifecycleOwner lifecycleOwner, Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner. final DisposablesubscribeForSingle(String eventType, ChatEventListener<ChatEvent> listener)Subscribes for the next event with the given eventType. final <T extends ChatEvent> DisposablesubscribeForSingle(Class<T> eventType, ChatEventListener<T> listener)Subscribes for the next event with the given eventType. final Call<Unit>clearPersistence()Clear local data stored on the device from the current user. final Call<Unit>disconnect(Boolean flushPersistence)Disconnect the current user, stop all observers and clear user data. final Call<List<Device>>getDevices()final Call<Unit>deleteDevice(Device device)final Call<Unit>addDevice(Device device)final UnitdismissChannelNotifications(String channelType, String channelId)Dismiss notifications from a given channelType and channelId. final Call<SearchMessagesResult>searchMessages(FilterObject channelFilter, FilterObject messageFilter, Integer offset, Integer limit, String next, QuerySorter<Message> sort)Search messages across channels. final Call<List<Message>>getPinnedMessages(String channelType, String channelId, Integer limit, QuerySorter<Message> sort, PinnedMessagesPagination pagination)Returns a list of messages pinned in the channel. final Call<Message>sendPoll(String channelType, String channelId, PollConfig pollConfig)Send a message with a poll to the given channel. final Call<Location>sendStaticLocation(String cid, Double latitude, Double longitude, String deviceId)Sends a static location message to the given channel. final Call<Location>startLiveLocationSharing(String cid, Double latitude, Double longitude, String deviceId, Date endAt)Starts live location sharing for the given channel. final Call<List<Location>>queryActiveLocations()Queries the active locations (non-expired) shared by the current user. final Call<Location>updateLiveLocation(String messageId, Double latitude, Double longitude, String deviceId)Updates the live location info of a message. final Call<Location>stopLiveLocationSharing(String messageId, String deviceId)Stops the live location sharing for a message. final Call<Option>suggestPollOption(String pollId, String option)final Call<Vote>castPollVote(String messageId, String pollId, Option option)Cast a vote for a poll in a message. final Call<Vote>castPollAnswer(String messageId, String pollId, String answer)final Call<Vote>removePollVote(String messageId, String pollId, Vote vote)Remove a vote for a poll in a message. final Call<Poll>closePoll(String pollId)Close a poll in a message. final Call<Unit>deletePoll(String pollId)Deletes a poll. final Call<List<Attachment>>getFileAttachments(String channelType, String channelId, Integer offset, Integer limit)Retrieves the file attachments from the given channel. final Call<List<Attachment>>getImageAttachments(String channelType, String channelId, Integer offset, Integer limit)Retrieves the image attachments from the given channel. final Call<List<Message>>getMessagesWithAttachments(String channelType, String channelId, Integer offset, Integer limit, List<String> types)Returns a Call with messages that contain at least one desired type attachment but not necessarily all of them will have a specified type. final Call<List<Message>>getReplies(String messageId, Integer limit)final Call<List<Message>>getNewerReplies(String parentId, Integer limit, String lastId)Fetch replies to the specified message with id parentId that are newer than the message with lastId. final Call<List<Message>>getRepliesMore(String messageId, String firstId, Integer limit)final Call<Message>sendAction(SendActionRequest request)final Call<Message>sendGiphy(Message message)Sends selected giphy message to the channel specified by Message.cid. final Call<Message>shuffleGiphy(Message message)Performs Giphy shuffle operation in the channel specified by Message.cid. final Call<Message>deleteMessage(String messageId, Boolean hard)Deletes a message. final Call<Message>deleteMessage(String messageId)Deletes a message. final Call<Message>getMessage(String messageId)Fetches a single message from the backend. final Call<Message>sendMessage(String channelType, String channelId, Message message, Boolean isRetrying)Sends the message to the given channel. final Call<DraftMessage>createDraftMessage(String channelType, String channelId, DraftMessage message)Create a new draft message. final Call<Unit>deleteDraftMessages(String channelType, String channelId, DraftMessage message)Delete a draft message. final Call<List<DraftMessage>>queryDraftMessages(Integer offset, Integer limit)Query draft messages for the current user. final Call<QueryDraftsResult>queryDrafts(FilterObject filter, Integer limit, String next, QuerySorter<DraftsSort> sort)Query draft messages for the current user. final Call<Message>updateMessage(Message message)Updates the message in the API and calls the plugins that handle this request. final Call<Message>partialUpdateMessage(String messageId, Map<String, Object> set, List<String> unset)Partially updates specific Message fields retaining the fields which were set previously. final Call<Member>pinChannel(String channelType, String channelId)Pin the channel for the current user. final Call<Member>unpinChannel(String channelType, String channelId)Unpin the channel for the current user. final Call<Member>archiveChannel(String channelType, String channelId)Archive the channel for the current user. final Call<Member>unarchiveChannel(String channelType, String channelId)Unarchive the channel for the current user. final Call<Message>pinMessage(Message message, Date expirationDate)Pins the message. final Call<Message>pinMessage(Message message, Integer timeout)Pins the message. final Call<Message>unpinMessage(Message message)Unpins the message that was previously pinned final Call<List<Channel>>queryChannelsInternal(QueryChannelsRequest request)Gets the channels without running any side effects. final Call<Channel>getChannel(String cid, Integer messageLimit, Integer memberLimit, Boolean state)Gets the channel from the server based on cid. final Call<Channel>getChannel(String channelType, String channelId, Integer messageLimit, Integer memberLimit, Boolean state)Gets the channel from the server based on channelType and channelId. final Call<Channel>queryChannel(String channelType, String channelId, QueryChannelRequest request, Boolean skipOnRequest)Gets the channel from the server based on channelType, channelId and parameters from QueryChannelRequest. final Call<List<Channel>>queryChannels(QueryChannelsRequest request)Gets the channels from the server based on parameters from QueryChannelsRequest. final Call<Channel>deleteChannel(String channelType, String channelId)Deletes the channel specified by the channelType and channelId. final Call<Unit>markMessageRead(String channelType, String channelId, String messageId)Marks the given message as read. final Call<Unit>markThreadRead(String channelType, String channelId, String threadId)Marks a given thread as read. final Call<Unit>showChannel(String channelType, String channelId)Shows the specified channel (if previously hidden). final Call<Unit>hideChannel(String channelType, String channelId, Boolean clearHistory)Hides the specified channel with side effects. final Call<Channel>truncateChannel(String channelType, String channelId, Message systemMessage)Removes all of the messages of the channel but doesn't affect the channel data or members. final Call<Unit>stopWatching(String channelType, String channelId)Stops watching the channel which means you won't receive more events for the channel. final Call<Channel>updateChannel(String channelType, String channelId, Message updateMessage, Map<String, Object> channelExtraData)Updates all of the channel data. final Call<Channel>updateChannelPartial(String channelType, String channelId, Map<String, Object> set, List<String> unset)Updates specific fields of channel data retaining the custom data fields which were set previously. final Call<Member>partialUpdateMember(String channelType, String channelId, String userId, Map<String, Object> set, List<String> unset)Updates specific fields of member data, retaining the custom data fields which were set previously. final Call<Channel>enableSlowMode(String channelType, String channelId, Integer cooldownTimeInSeconds)Enables slow mode for the channel. final Call<Channel>disableSlowMode(String channelType, String channelId)Disables slow mode for the channel. final Call<Channel>acceptInvite(String channelType, String channelId, String message)Accepts the invitation to join a channel. final Call<Channel>rejectInvite(String channelType, String channelId)Rejects the invitation to join the channel. final Call<ChatEvent>sendEvent(String eventType, String channelType, String channelId, Map<Object, Object> extraData)Sends an event to all users watching the channel. final Call<UnreadCounts>getUnreadCounts()Gets the unread counts for the current user. final Call<Unit>markAllRead()Marks all the channel as read. final Call<Unit>markRead(String channelType, String channelId)Marks the specified channel as read. final Call<Unit>markUnread(String channelType, String channelId, String messageId)Marks the specified channel as unread. final Call<Unit>markThreadUnread(String channelType, String channelId, String threadId, String messageId)Marks a given thread starting from the given message as unread. final Call<List<User>>updateUsers(List<User> users)Updates multiple users in a single request. final Call<User>updateUser(User user)Updates a single user. final Call<UserBlock>blockUser(String userId)Block a user by ID. final Call<Unit>unblockUser(String userId)Unblock a user by ID. final Call<List<UserBlock>>queryBlockedUsers()Return na list of blocked users. final Call<User>partialUpdateUser(String id, Map<String, Object> set, List<String> unset)Updates specific user fields retaining the custom data fields which were set previously. final Call<List<User>>queryUsers(QueryUsersRequest query)Query users matching query request. final Call<Channel>addMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean hideHistory, Boolean skipPush)Adds members to a given channel. final Call<Channel>addMembers(String channelType, String channelId, AddMembersParams params)Adds members to a given channel. final Call<Channel>removeMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean skipPush)Removes members from a given channel. final Call<Channel>inviteMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean skipPush)Invites members to a given channel. final Call<Unit>muteChannel(String channelType, String channelId, Integer expiration)Mutes a channel for the current user. final Call<Unit>muteChannel(String channelType, String channelId)Mutes a channel for the current user. final Call<Unit>unmuteChannel(String channelType, String channelId)Unmutes a channel for the current user. final Call<Mute>muteUser(String userId, Integer timeout)Mutes a user. final Call<Mute>muteUser(String userId)Mutes a user. final Call<Unit>unmuteUser(String userId)Unmutes a previously muted user. final Call<Unit>unmuteCurrentUser()final Call<Mute>muteCurrentUser()final Call<Flag>flagUser(String userId, String reason, Map<String, String> customData)Flags a user. final Call<Flag>unflagUser(String userId)Un-flags a previously flagged user. final Call<Flag>flagMessage(String messageId, String reason, Map<String, String> customData)Flags a message. final Call<Flag>unflagMessage(String messageId)Un-flags a previously flagged message. final Call<Message>translate(String messageId, String language)Translate a message. final Call<Attachment>enrichUrl(String url)Enriches the given URL with Open Graph data. final Call<Unit>banUser(String targetId, String channelType, String channelId, String reason, Integer timeout)Bans a user from a given channel. final Call<Unit>unbanUser(String targetId, String channelType, String channelId)Unbans a user from a given channel. final Call<Unit>shadowBanUser(String targetId, String channelType, String channelId, String reason, Integer timeout)Shadow bans a user from a given channel. final Call<Unit>removeShadowBan(String targetId, String channelType, String channelId)Removes a shadow ban from a user in a given channel. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore, Date createdAtBeforeOrEqual)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort)Queries the banned users matching the provided filters. final Call<List<BannedUser>>queryBannedUsers(FilterObject filter)Queries the banned users matching the provided filters. final UnitsetPushNotificationReceivedListener(PushNotificationReceivedListener pushNotificationReceivedListener)final StringgetConnectionId()final UsergetCurrentUser()final StringgetCurrentOrStoredUserId()final StringgetCurrentToken()Retrieves the current user token (or null if it doesn't exist). final AppSettingsgetAppSettings()Returns application settings from the server or the default ones as a fallback. final BooleanisSocketConnected()Checks if the chat socket is connected. final ChannelClientchannel(String channelType, String channelId)Returns a ChannelClient for given type and id. final ChannelClientchannel(String cid)Returns a ChannelClient for given cid. final Call<Channel>createChannel(String channelType, String channelId, List<String> memberIds, Map<String, Object> extraData)Creates the channel. final Call<Channel>createChannel(String channelType, String channelId, CreateChannelParams params)Creates the channel. final Call<List<ChatEvent>>getSyncHistory(List<String> channelsIds, Date lastSyncAt)Returns all events that happened for a list of channels since last sync (while the user was not connected to the web-socket). final Call<List<ChatEvent>>getSyncHistory(List<String> channelsIds, String lastSyncAt)Returns all events that happened for a list of channels since last sync (while the user was not connected to the web socket). final Call<ChatEvent>keystroke(String channelType, String channelId, String parentId)Sends a EventType.TYPING_START event to the backend. final Call<ChatEvent>stopTyping(String channelType, String channelId, String parentId)Sends a EventType.TYPING_STOP event to the backend. final Call<VideoCallInfo>createVideoCall(String channelType, String channelId, String callType, String callId)Creates a newly available video call, which belongs to a channel. final Call<VideoCallToken>getVideoCallToken(String callId)Returns the currently available video call token. final Call<ResponseBody>downloadFile(String fileUrl)Downloads the given file which can be fetched through the response body. final Call<List<Thread>>queryThreads(QueryThreadsRequest query)Query threads matching query request. final Call<QueryThreadsResult>queryThreadsResult(QueryThreadsRequest query)Query threads matching query request. final Call<Thread>getThread(String messageId, GetThreadOptions options)Get a thread by message id. final Call<Thread>partialUpdateThread(String messageId, Map<String, Object> set, List<String> unset)Partially updates specific Thread fields retaining the fields which were set previously. final Call<MessageReminder>createReminder(String messageId, Date remindAt)Creates a reminder for a message. final Call<MessageReminder>updateReminder(String messageId, Date remindAt)Updates an existing reminder for a message. final Call<Unit>deleteReminder(String messageId)Deletes a reminder for a message. final Call<QueryRemindersResult>queryReminders(FilterObject filter, Integer limit, String next, QuerySorter<MessageReminder> sort)Queries the message reminders for the current user matching the provided filters. final StringdevToken(String userId)Generate a developer token that can be used to connect users while the app is using a development environment. final static ChatClientinstance()final static UnithandlePushMessage(PushMessage pushMessage)Handles push message. -
-
Method Detail
-
getClientState
final ClientState getClientState()
-
getRepositoryFacade
final RepositoryFacade getRepositoryFacade()
-
getPlugins
final List<Plugin> getPlugins()
The list of plugins added once user is connected.
-
setPlugins
final Unit setPlugins(List<Plugin> plugins)
The list of plugins added once user is connected.
-
getLogicRegistry
final ChannelStateLogicProvider getLogicRegistry()
-
setLogicRegistry
final Unit setLogicRegistry(ChannelStateLogicProvider logicRegistry)
-
getConfig
final ChatClientConfig getConfig()
-
getPluginFactories
final List<PluginFactory> getPluginFactories()
-
getAudioPlayer
final AudioPlayer getAudioPlayer()
-
inheritScope
final CoroutineScope inheritScope(Function1<Job, CoroutineContext> block)
Inherits the UserScope and provides its Job as an anchor for children.
-
resolveDependency
final <DR extends DependencyResolver, T extends Any> T resolveDependency()
Resolves dependency T within the provided plugin DR. This method can't be called before user is connected because plugins are added only after user connection is completed.
-
awaitInitializationState
@StreamHandsOff(reason = "This method is used to avoid race-condition between plugin initialization and dependency resolution.") final InitializationState awaitInitializationState(Long timeoutMilliseconds)
-
appSettings
@CheckResult() final Call<AppSettings> appSettings()
Get the current settings of the app. Check AppSettings.
- Returns:
AppSettings the settings of the app.
-
connectUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds)
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.
This method performs required operations before connecting with the Stream API. Moreover, it warms up the connection, sets up notifications, and connects to the socket.
Check out docs for more info about tokens. Also visit this site to find more about Json Web Token standard. You can generate the JWT token on using one of the available libraries or use our manual tool for token generation.
- Parameters:
user- The user to set.tokenProvider- A TokenProvider implementation.timeoutMilliseconds- The timeout in milliseconds to be waiting until the connection is established.- Returns:
Executable Call responsible for connecting the user.
-
connectUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectUser(User user, TokenProvider tokenProvider)
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.
This method performs required operations before connecting with the Stream API. Moreover, it warms up the connection, sets up notifications, and connects to the socket.
Check out docs for more info about tokens. Also visit this site to find more about Json Web Token standard. You can generate the JWT token on using one of the available libraries or use our manual tool for token generation.
- Parameters:
user- The user to set.tokenProvider- A TokenProvider implementation.- Returns:
Executable Call responsible for connecting the user.
-
connectUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectUser(User user, String token, Long timeoutMilliseconds)
Initializes ChatClient for a specific user using the given user token. Check ChatClient.connectUser with TokenProvider parameter for advanced use cases.
- Parameters:
user- Instance of User type.token- Instance of JWT token.- Returns:
Executable Call responsible for connecting the user.
-
connectUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectUser(User user, String token)
Initializes ChatClient for a specific user using the given user token. Check ChatClient.connectUser with TokenProvider parameter for advanced use cases.
- Parameters:
user- Instance of User type.token- Instance of JWT token.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds, Function0<Unit> onDisconnectionComplete)
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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.tokenProvider- A TokenProvider implementation.timeoutMilliseconds- The timeout in milliseconds to be waiting until the connection is established.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, TokenProvider tokenProvider, Long timeoutMilliseconds)
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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.tokenProvider- A TokenProvider implementation.timeoutMilliseconds- The timeout in milliseconds to be waiting until the connection is established.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, TokenProvider tokenProvider)
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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.tokenProvider- A TokenProvider implementation.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, String token, Long timeoutMilliseconds, Function0<Unit> onDisconnectionComplete)
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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.token- Instance of JWT token.timeoutMilliseconds- The timeout in milliseconds to be waiting until the connection is established.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, String token, Long timeoutMilliseconds)
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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.token- Instance of JWT token.timeoutMilliseconds- The timeout in milliseconds to be waiting until the connection is established.- Returns:
Executable Call responsible for connecting the user.
-
switchUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> switchUser(User user, String 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.
This method disconnects from the SDK and right after connects to it with the new User.
- Parameters:
user- The user to set.token- Instance of JWT token.- Returns:
Executable Call responsible for connecting the user.
-
containsStoredCredentials
final Boolean containsStoredCredentials()
Checks if there are currently stored user credentials in the local storage.
-
connectAnonymousUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectAnonymousUser(Long timeoutMilliseconds)
-
connectAnonymousUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectAnonymousUser()
-
connectGuestUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectGuestUser(String userId, String username, Long timeoutMilliseconds)
-
connectGuestUser
@CheckResult()@JvmOverloads() final Call<ConnectionData> connectGuestUser(String userId, String username)
-
getGuestToken
@CheckResult() final Call<GuestUser> getGuestToken(String userId, String userName)
-
queryMembers
@CheckResult() final Call<List<Member>> queryMembers(String channelType, String channelId, Integer offset, Integer limit, FilterObject filter, QuerySorter<Member> sort, List<Member> members)
Query members and apply side effects if there are any.
- Parameters:
channelType- The type of channel.channelId- The id of the channel.offset- Offset limit.limit- Number of members to fetch.filter- FilterObject to filter members of certain type.sort- Sort the list of members.members- List of members to search in distinct channels.- Returns:
Call with a list of members or an error.
-
sendFile
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(String channelType, String channelId, File file, ProgressCallback callback)
Uploads a file for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on file uploads:
The maximum file size is 100 MB
- Parameters:
channelType- The channel type.channelId- The channel id.file- The file that needs to be uploaded.callback- The callback to track progress.- Returns:
Executable async Call which completes with Result containing an instance of UploadedFile if the file was successfully uploaded.
-
sendFile
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(String channelType, String channelId, File file)
Uploads a file for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on file uploads:
The maximum file size is 100 MB
- Parameters:
channelType- The channel type.channelId- The channel id.file- The file that needs to be uploaded.- Returns:
Executable async Call which completes with Result containing an instance of UploadedFile if the file was successfully uploaded.
-
sendImage
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendImage(String channelType, String channelId, File file, ProgressCallback callback)
Uploads an image for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on image uploads:
The maximum image size is 100 MB
Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES
- Parameters:
channelType- The channel type.channelId- Еhe channel id.file- The image file that needs to be uploaded.callback- The callback to track progress.- Returns:
Executable async Call which completes with Result containing an instance of UploadedImage if the image was successfully uploaded.
-
sendImage
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendImage(String channelType, String channelId, File file)
Uploads an image for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on image uploads:
The maximum image size is 100 MB
Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES
- Parameters:
channelType- The channel type.channelId- Еhe channel id.file- The image file that needs to be uploaded.- Returns:
Executable async Call which completes with Result containing an instance of UploadedImage if the image was successfully uploaded.
-
deleteFile
@CheckResult() final Call<Unit> deleteFile(String channelType, String channelId, String url)
Deletes the file represented by url from the given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.url- The URL of the file to be deleted.- Returns:
Executable async Call responsible for deleting a file.
-
deleteImage
@CheckResult() final Call<Unit> deleteImage(String channelType, String channelId, String url)
Deletes the image represented by url from the given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.url- The URL of the image to be deleted.- Returns:
Executable async Call responsible for deleting an image.
-
getReactions
@CheckResult() final Call<List<Reaction>> getReactions(String messageId, Integer offset, Integer limit)
Retrieves the reactions on a given message.
- Parameters:
messageId- The ID of the message to which the reactions belong.offset- The offset of the first reaction to retrieve.limit- The maximum number of reactions to retrieve.
-
deleteReaction
@CheckResult() final Call<Message> deleteReaction(String messageId, String reactionType, String cid)
Deletes the reaction associated with the message with the given message id. cid parameter is being used in side effect functions executed by plugins. You can skip it if plugins are not being used.
The call will be retried accordingly to retryPolicy.
- Parameters:
messageId- The id of the message to which reaction belongs.reactionType- The type of reaction.cid- The full channel id, i.e.- Returns:
Executable async Call responsible for deleting the reaction.
-
sendReaction
@CheckResult()@JvmOverloads() final Call<Reaction> sendReaction(Reaction reaction, Boolean enforceUnique, String cid)
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.
The call will be retried accordingly to retryPolicy.
- Parameters:
reaction- The Reaction to send.enforceUnique- Flag to determine whether the reaction should replace other ones added by the current user.cid- The full channel id, i.e.- Returns:
Executable async Call responsible for sending the reaction.
-
sendReaction
@CheckResult()@JvmOverloads() final Call<Reaction> sendReaction(Reaction reaction, Boolean enforceUnique)
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.
The call will be retried accordingly to retryPolicy.
- Parameters:
reaction- The Reaction to send.enforceUnique- Flag to determine whether the reaction should replace other ones added by the current user.- Returns:
Executable async Call responsible for sending the reaction.
-
disconnectSocket
@CheckResult() final Call<Unit> disconnectSocket()
-
fetchCurrentUser
final Call<User> fetchCurrentUser()
Fetches the current user. Works only if the user was previously set and the WS connections is closed.
-
reconnectSocket
@CheckResult() final Call<Unit> reconnectSocket()
Reconnects the socket. Works only if the user was previously set and the WS connections is closed.
-
addSocketListener
final Unit addSocketListener(SocketListener listener)
-
removeSocketListener
final Unit removeSocketListener(SocketListener listener)
-
subscribe
final Disposable subscribe(ChatEventListener<ChatEvent> listener)
-
subscribeFor
final Disposable subscribeFor(String eventTypes, ChatEventListener<ChatEvent> listener)
Subscribes to the specific eventTypes of the client.
-
subscribeFor
final Disposable subscribeFor(LifecycleOwner lifecycleOwner, String eventTypes, ChatEventListener<ChatEvent> listener)
Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner.
Only receives events when the lifecycle is in a STARTED state, otherwise events are dropped.
-
subscribeFor
final Disposable subscribeFor(Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)
Subscribes to the specific eventTypes of the client.
-
subscribeFor
final Disposable subscribeFor(LifecycleOwner lifecycleOwner, Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)
Subscribes to the specific eventTypes of the client, in the lifecycle of lifecycleOwner.
Only receives events when the lifecycle is in a STARTED state, otherwise events are dropped.
-
subscribeForSingle
final Disposable subscribeForSingle(String eventType, ChatEventListener<ChatEvent> listener)
Subscribes for the next event with the given eventType.
-
subscribeForSingle
final <T extends ChatEvent> Disposable subscribeForSingle(Class<T> eventType, ChatEventListener<T> listener)
Subscribes for the next event with the given eventType.
-
clearPersistence
@CheckResult() final Call<Unit> clearPersistence()
Clear local data stored on the device from the current user.
This method can be called even if the user is not connected, on that case the stored credentials will be used.
If there is already a connection alive for the current user, it will be disconnected.
- Returns:
Executable async Call which performs the cleanup.
-
disconnect
@CheckResult() final Call<Unit> disconnect(Boolean flushPersistence)
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.
- Parameters:
flushPersistence- if true will clear user data.- Returns:
Executable async Call which performs the disconnection.
-
getDevices
@CheckResult() final Call<List<Device>> getDevices()
-
deleteDevice
@CheckResult() final Call<Unit> deleteDevice(Device device)
-
addDevice
@CheckResult() final Call<Unit> addDevice(Device device)
-
dismissChannelNotifications
final Unit dismissChannelNotifications(String channelType, String channelId)
Dismiss notifications from a given channelType and channelId. Be sure to initialize ChatClient before calling this method!
- Parameters:
channelType- String that represent the channel type of the channel you want to dismiss notifications.channelId- String that represent the channel id of the channel you want to dismiss notifications.
-
searchMessages
@CheckResult() final Call<SearchMessagesResult> searchMessages(FilterObject channelFilter, FilterObject messageFilter, Integer offset, Integer limit, String next, QuerySorter<Message> sort)
Search messages across channels. There are two ways to paginate through search results:
Limit and offset will allow you to access up to 1000 results matching your query. You will not be able to sort using limit and offset. The results will instead be sorted by relevance and message ID.
Next pagination will allow you to access all search results that match your query, and you will be able to sort using any filter-able fields and custom fields. Pages of sort results will be returned with next and previous strings which can be supplied as a next parameter when making a query to get a new page of results.
- Parameters:
channelFilter- Channel filter conditions.messageFilter- Message filter conditions.offset- Pagination offset, cannot be used with sort or next.limit- The number of messages to return.next- Pagination parameter, cannot be used with non-zero offset.sort- The sort criteria applied to the result, cannot be used with non-zero offset.- Returns:
Executable async Call responsible for searching messages across channels.
-
getPinnedMessages
@CheckResult() final Call<List<Message>> getPinnedMessages(String channelType, String channelId, Integer limit, QuerySorter<Message> sort, PinnedMessagesPagination pagination)
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.
- Parameters:
channelType- The channel type.channelId- The id of the channel we're querying.limit- Max limit of messages to be fetched.sort- Parameter by which we sort the messages.pagination- Provides different options for pagination.- Returns:
Executable async Call responsible for getting pinned messages.
-
sendPoll
@CheckResult() final Call<Message> sendPoll(String channelType, String channelId, PollConfig pollConfig)
Send a message with a poll to the given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.pollConfig- The poll configuration.- Returns:
Executable async Call responsible for sending a poll.
-
sendStaticLocation
@CheckResult() final Call<Location> sendStaticLocation(String cid, Double latitude, Double longitude, String deviceId)
Sends a static location message to the given channel.
- Parameters:
cid- The full channel id, i.e.latitude- The latitude of the location.longitude- The longitude of the location.deviceId- The device ID from which the location is sent.
-
startLiveLocationSharing
@CheckResult() final Call<Location> startLiveLocationSharing(String cid, Double latitude, Double longitude, String deviceId, Date endAt)
Starts live location sharing for the given channel.
- Parameters:
cid- The full channel id, i.e.latitude- The latitude of the location.longitude- The longitude of the location.deviceId- The device ID from which the location is shared.endAt- The date when the live location sharing will end.
-
queryActiveLocations
@CheckResult() final Call<List<Location>> queryActiveLocations()
Queries the active locations (non-expired) shared by the current user.
-
updateLiveLocation
@CheckResult() final Call<Location> updateLiveLocation(String messageId, Double latitude, Double longitude, String deviceId)
Updates the live location info of a message.
- Parameters:
messageId- The ID of the message to update.latitude- The latitude of the new location.longitude- The longitude of the new location.deviceId- The device ID from which the location is shared.
-
stopLiveLocationSharing
@CheckResult() final Call<Location> stopLiveLocationSharing(String messageId, String deviceId)
Stops the live location sharing for a message.
- Parameters:
messageId- The ID of the message to stop sharing live location.deviceId- The device ID from which the location is shared.
-
suggestPollOption
@CheckResult() final Call<Option> suggestPollOption(String pollId, String option)
-
castPollVote
@CheckResult() final Call<Vote> castPollVote(String messageId, String pollId, Option option)
Cast a vote for a poll in a message.
- Parameters:
messageId- The message id where the poll is.pollId- The poll id.option- The option to vote for.- Returns:
Executable async Call responsible for casting a vote.
-
castPollAnswer
@CheckResult() final Call<Vote> castPollAnswer(String messageId, String pollId, String answer)
-
removePollVote
@CheckResult() final Call<Vote> removePollVote(String messageId, String pollId, Vote vote)
Remove a vote for a poll in a message.
- Parameters:
messageId- The message id where the poll is.pollId- The poll id.vote- The vote to remove.- Returns:
Executable async Call responsible for removing a vote.
-
closePoll
@CheckResult() final Call<Poll> closePoll(String pollId)
Close a poll in a message.
- Parameters:
pollId- The poll id.- Returns:
Executable async Call responsible for closing a poll.
-
deletePoll
@CheckResult() final Call<Unit> deletePoll(String pollId)
Deletes a poll.
- Parameters:
pollId- The ID of the poll to delete.- Returns:
Executable async Call responsible for deleting a poll.
-
getFileAttachments
@CheckResult() final Call<List<Attachment>> getFileAttachments(String channelType, String channelId, Integer offset, Integer limit)
Retrieves the file attachments from the given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.offset- The attachments offset.limit- Max limit attachments to be fetched.
-
getImageAttachments
@CheckResult() final Call<List<Attachment>> getImageAttachments(String channelType, String channelId, Integer offset, Integer limit)
Retrieves the image attachments from the given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.offset- The attachments offset.limit- Max limit attachments to be fetched.
-
getMessagesWithAttachments
@CheckResult() final Call<List<Message>> getMessagesWithAttachments(String channelType, String channelId, Integer offset, Integer limit, List<String> types)
Returns a Call with messages that contain at least one desired type attachment but not necessarily all of them will have a specified type.
- Parameters:
channelType- The channel type.channelId- The channel id.offset- The messages offset.limit- Max limit messages to be fetched.types- Desired attachment's types list.
-
getReplies
@CheckResult() final Call<List<Message>> getReplies(String messageId, Integer limit)
-
getNewerReplies
@CheckResult() final Call<List<Message>> getNewerReplies(String parentId, Integer limit, String lastId)
Fetch replies to the specified message with id parentId that are newer than the message with lastId. If lastId is null, the oldest replies are returned.
- Parameters:
parentId- The id of the parent message.limit- The number of replies to fetch.lastId- The id of the last message to fetch from exclusively.- Returns:
Executable async Call responsible for fetching newer replies.
-
getRepliesMore
@CheckResult() final Call<List<Message>> getRepliesMore(String messageId, String firstId, Integer limit)
-
sendAction
@CheckResult() final Call<Message> sendAction(SendActionRequest request)
-
sendGiphy
@CheckResult() final Call<Message> sendGiphy(Message message)
Sends selected giphy message to the channel specified by Message.cid. The call will be retried accordingly to retryPolicy.
- Parameters:
message- The message to send.- Returns:
Executable async Call responsible for sending the Giphy.
-
shuffleGiphy
@CheckResult() final Call<Message> shuffleGiphy(Message message)
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.
- Parameters:
message- The message to send.- Returns:
Executable async Call responsible for shuffling the Giphy.
-
deleteMessage
@CheckResult()@JvmOverloads() final Call<Message> deleteMessage(String messageId, Boolean hard)
Deletes a message.
- Parameters:
messageId- The ID of the message to be deleted.hard- True if the message should be hard deleted.
-
deleteMessage
@CheckResult()@JvmOverloads() final Call<Message> deleteMessage(String messageId)
Deletes a message.
- Parameters:
messageId- The ID of the message to be deleted.
-
getMessage
@CheckResult() final Call<Message> getMessage(String messageId)
Fetches a single message from the backend.
- Parameters:
messageId- The ID of the message we are fetching from the backend.- Returns:
The message wrapped inside Result if the call was successful, otherwise returns a Error instance wrapped inside Result.
-
sendMessage
@CheckResult() final Call<Message> sendMessage(String channelType, String channelId, Message message, Boolean isRetrying)
Sends the message to the given channel. If isRetrying is set to true, the message may not be prepared again.
- Parameters:
channelType- The channel type.channelId- The channel id.message- Message objectisRetrying- True if this message is being retried.- Returns:
Executable async Call responsible for sending a message.
-
createDraftMessage
@CheckResult() final Call<DraftMessage> createDraftMessage(String channelType, String channelId, DraftMessage message)
Create a new draft message. The call will be retried accordingly to retryPolicy.
- Parameters:
channelType- The channel type.channelId- The channel id.message- The draft message to create.- Returns:
Executable async Call responsible for creating a draft message.
-
deleteDraftMessages
@CheckResult() final Call<Unit> deleteDraftMessages(String channelType, String channelId, DraftMessage message)
Delete a draft message. The call will be retried accordingly to retryPolicy.
- Parameters:
channelType- The channel type.channelId- The channel id.message- The draft message to delete.- Returns:
Executable async Call responsible for deleting a draft message.
-
queryDraftMessages
@Deprecated(message = "The offset param in the queryDraftMessages method is not used. Use the queryDrafts method instead.", replaceWith = @ReplaceWith(imports = {}, expression = "queryDrafts(filter, limit, next, sort)"))@CheckResult() final Call<List<DraftMessage>> queryDraftMessages(Integer offset, Integer limit)
- Parameters:
offset- The offset to start querying from.limit- The number of draft messages to return.- Returns:
Executable async Call responsible for querying draft messages.
-
queryDrafts
@CheckResult() final Call<QueryDraftsResult> queryDrafts(FilterObject filter, Integer limit, String next, QuerySorter<DraftsSort> sort)
Query draft messages for the current user.
- Parameters:
filter- The filter to apply to the query.limit- The number of draft messages to return.next- The pagination token for the next page of results.sort- The sorting criteria for the results.
-
updateMessage
@CheckResult() final Call<Message> updateMessage(Message message)
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.
- Parameters:
message- Message The message to be updated.
-
partialUpdateMessage
@CheckResult() final Call<Message> partialUpdateMessage(String messageId, Map<String, Object> set, List<String> unset)
Partially updates specific Message fields retaining the fields which were set previously.
- Parameters:
messageId- The message ID.set- The key-value data which will be added to the existing message object.unset- The list of fields which will be removed from the existing message object.- Returns:
Executable async Call responsible for partially updating the message.
-
pinChannel
final Call<Member> pinChannel(String channelType, String channelId)
Pin the channel for the current user.
- Parameters:
channelType- The channel type.channelId- The channel ID.- Returns:
Executable async Call responsible for pinning the channel.
-
unpinChannel
final Call<Member> unpinChannel(String channelType, String channelId)
Unpin the channel for the current user.
- Parameters:
channelType- The channel type.channelId- The channel ID.- Returns:
Executable async Call responsible for unpinning the channel.
-
archiveChannel
final Call<Member> archiveChannel(String channelType, String channelId)
Archive the channel for the current user.
- Parameters:
channelType- The channel type.channelId- The channel ID.- Returns:
Executable async Call responsible for archiving the channel.
-
unarchiveChannel
final Call<Member> unarchiveChannel(String channelType, String channelId)
Unarchive the channel for the current user.
- Parameters:
channelType- The channel type.channelId- The channel ID.- Returns:
Executable async Call responsible for un-archiving the channel.
-
pinMessage
@CheckResult() final Call<Message> pinMessage(Message message, Date expirationDate)
Pins the message.
- Parameters:
message- The message object containing the ID of the message to be pinned.expirationDate- The exact expiration date.- Returns:
Executable async Call responsible for pinning the message.
-
pinMessage
@CheckResult() final Call<Message> pinMessage(Message message, Integer timeout)
Pins the message.
- Parameters:
message- The message object containing the ID of the message to be pinned.timeout- The expiration timeout in seconds.- Returns:
Executable async Call responsible for pinning the message.
-
unpinMessage
@CheckResult() final Call<Message> unpinMessage(Message message)
Unpins the message that was previously pinned
- Parameters:
message- The message object containing the ID of the message to be unpinned.- Returns:
Executable async Call responsible for unpinning the message.
-
queryChannelsInternal
@CheckResult() final Call<List<Channel>> queryChannelsInternal(QueryChannelsRequest request)
Gets the channels without running any side effects.
- Parameters:
request- The request's parameters combined into QueryChannelsRequest class.- Returns:
Executable async Call responsible for querying channels.
-
getChannel
final Call<Channel> getChannel(String cid, Integer messageLimit, Integer memberLimit, Boolean state)
Gets the channel from the server based on cid.
- Parameters:
cid- The full channel id.messageLimit- The number of messages to retrieve for the channel.memberLimit- The number of members to retrieve for the channel.state- if true returns the Channel state.
-
getChannel
final Call<Channel> getChannel(String channelType, String channelId, Integer messageLimit, Integer memberLimit, Boolean state)
Gets the channel from the server based on channelType and channelId.
- Parameters:
channelType- The channel type.channelId- The channel id.messageLimit- The number of messages to retrieve for the channel.memberLimit- The number of members to retrieve for the channel.state- if true returns the Channel state.
-
queryChannel
@CheckResult() final Call<Channel> queryChannel(String channelType, String channelId, QueryChannelRequest request, Boolean skipOnRequest)
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.
- Parameters:
request- The request's parameters combined into QueryChannelRequest class.- Returns:
Executable async Call responsible for querying channels.
-
queryChannels
@CheckResult() final Call<List<Channel>> queryChannels(QueryChannelsRequest request)
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.
- Parameters:
request- The request's parameters combined into QueryChannelsRequest class.- Returns:
Executable async Call responsible for querying channels.
-
deleteChannel
@CheckResult() final Call<Channel> deleteChannel(String channelType, String channelId)
Deletes the channel specified by the channelType and channelId.
- Parameters:
channelType- The type of the channel.channelId- The ID of the channel.
-
markMessageRead
@CheckResult() final Call<Unit> markMessageRead(String channelType, String channelId, String messageId)
Marks the given message as read.
- Parameters:
channelType- The type of the channel in which the thread resides.channelId- The ID of the channel in which the thread resides.messageId- The ID of the message to mark as read.
-
markThreadRead
@CheckResult() final Call<Unit> markThreadRead(String channelType, String channelId, String threadId)
Marks a given thread as read.
- Parameters:
channelType- The type of the channel in which the thread resides.channelId- The ID of the channel in which the thread resides.threadId- The ID of the thread to mark as read.
-
showChannel
@CheckResult() final Call<Unit> showChannel(String channelType, String channelId)
Shows the specified channel (if previously hidden).
- Parameters:
channelType- The type of the channel.channelId- Id of the channel.
-
hideChannel
@CheckResult() final Call<Unit> hideChannel(String channelType, String channelId, Boolean clearHistory)
Hides the specified channel with side effects.
- Parameters:
channelType- The type of the channel.channelId- Id of the channel.clearHistory- Boolean, if you want to clear the history of this channel or not.- Returns:
Executable async Call responsible for hiding a channel.
-
truncateChannel
@CheckResult() final Call<Channel> truncateChannel(String channelType, String channelId, Message systemMessage)
Removes all of the messages of the channel but doesn't affect the channel data or members.
- Parameters:
channelType- The channel type.channelId- The channel id.systemMessage- The system message that will be shown in the channel.- Returns:
Executable async Call which completes with Result having data equal to the truncated channel if the channel was successfully truncated.
-
stopWatching
@CheckResult() final Call<Unit> stopWatching(String channelType, String channelId)
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.
- Parameters:
channelType- The channel type.channelId- The channel id.- Returns:
Executable async Call responsible for stop watching the channel.
-
updateChannel
@CheckResult() final Call<Channel> updateChannel(String channelType, String channelId, Message updateMessage, Map<String, Object> channelExtraData)
Updates all of the channel data. Any data that is present on the channel and not included in a full update will be deleted.
- Parameters:
channelType- The channel type.channelId- The channel id.updateMessage- The message object allowing you to show a system message in the channel.channelExtraData- The updated channel extra data.- Returns:
Executable async Call responsible for updating channel data.
-
updateChannelPartial
@CheckResult() final Call<Channel> updateChannelPartial(String channelType, String channelId, Map<String, Object> set, List<String> unset)
Updates specific fields of channel data retaining the custom data fields which were set previously.
- Parameters:
channelType- The channel type.channelId- The channel id.set- The key-value data which will be added to the existing channel data object.unset- The list of fields which will be removed from the existing channel data object.- Returns:
Executable async Call responsible for updating channel data.
-
partialUpdateMember
@CheckResult() final Call<Member> partialUpdateMember(String channelType, String channelId, String userId, Map<String, Object> set, List<String> unset)
Updates specific fields of member data, retaining the custom data fields which were set previously.
- Parameters:
channelType- The channel type.channelId- The channel id.userId- The ID of the member to be updated.set- The key-value data to be updated in the member data.unset- The list of keys to be removed from the member data.- Returns:
Executable async Call responsible for updating member data.
-
enableSlowMode
@CheckResult() final Call<Channel> enableSlowMode(String channelType, String channelId, Integer cooldownTimeInSeconds)
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.
- Parameters:
channelType- The channel type.channelId- The channel id.cooldownTimeInSeconds- The duration of the time interval users have to wait between messages.- Returns:
Executable async Call responsible for enabling slow mode.
-
disableSlowMode
@CheckResult() final Call<Channel> disableSlowMode(String channelType, String channelId)
Disables slow mode for the channel.
- Parameters:
channelType- The channel type.channelId- The channel id.- Returns:
Executable async Call responsible for disabling slow mode.
-
acceptInvite
@CheckResult() final Call<Channel> acceptInvite(String channelType, String channelId, String message)
Accepts the invitation to join a channel.
- Parameters:
channelType- The channel type.channelId- The channel id.message- The message to send with the accept invitation.
-
rejectInvite
@CheckResult() final Call<Channel> rejectInvite(String channelType, String channelId)
Rejects the invitation to join the channel.
- Parameters:
channelType- The channel type.channelId- The channel id.
-
sendEvent
@CheckResult() final Call<ChatEvent> sendEvent(String eventType, String channelType, String channelId, Map<Object, Object> extraData)
Sends an event to all users watching the channel.
- Parameters:
eventType- The event name.channelType- The channel type.channelId- The channel id.extraData- The event payload.- Returns:
Executable async Call responsible for sending an event.
-
getUnreadCounts
final Call<UnreadCounts> getUnreadCounts()
Gets the unread counts for the current user.
-
markAllRead
@CheckResult() final Call<Unit> markAllRead()
Marks all the channel as read.
- Returns:
Result Empty unit result.
-
markRead
@CheckResult() final Call<Unit> markRead(String channelType, String channelId)
Marks the specified channel as read.
- Parameters:
channelType- Type of the channel.channelId- Id of the channel.
-
markUnread
@CheckResult() final Call<Unit> markUnread(String channelType, String channelId, String messageId)
Marks the specified channel as unread.
- Parameters:
channelType- Type of the channel.channelId- Id of the channel.messageId- Id of the message.
-
markThreadUnread
@CheckResult() final Call<Unit> markThreadUnread(String channelType, String channelId, String threadId, String messageId)
Marks a given thread starting from the given message as unread.
- Parameters:
channelType- Type of the channel.channelId- Id of the channel.threadId- Id of the thread to mark as unread.messageId- Id of the message from where the thread should be marked as unread.
-
updateUsers
@CheckResult() final Call<List<User>> updateUsers(List<User> users)
Updates multiple users in a single request.
- Parameters:
users- The list of users to be updated.
-
updateUser
@CheckResult() final Call<User> updateUser(User user)
Updates a single user.
- Parameters:
user- The user to be updated.
-
blockUser
@CheckResult() final Call<UserBlock> blockUser(String userId)
Block a user by ID.
- Parameters:
userId- the ID of the user that will be blocked.- Returns:
a list of UserBlock which will contain the block that just occured.
-
unblockUser
@CheckResult() final Call<Unit> unblockUser(String userId)
Unblock a user by ID.
- Parameters:
userId- the user ID of the user that will be unblocked.
-
queryBlockedUsers
@CheckResult() final Call<List<UserBlock>> queryBlockedUsers()
Return na list of blocked users.
-
partialUpdateUser
@CheckResult() final Call<User> partialUpdateUser(String id, Map<String, Object> set, List<String> unset)
Updates specific user fields retaining the custom data fields which were set previously.
- Parameters:
id- User ids.set- The key-value data which will be added to the existing user object.unset- The list of fields which will be removed from the existing user object.- Returns:
Executable async Call.
-
queryUsers
@CheckResult() final Call<List<User>> queryUsers(QueryUsersRequest query)
Query users matching query request.
The call requires active socket connection if QueryUsersRequest.presence is enabled, and will be automatically postponed and retried until the connection is established.
- Parameters:
query- QueryUsersRequest with query parameters like filters, sort to get matching users.- Returns:
Call with a list of User.
-
addMembers
@CheckResult() final Call<Channel> addMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean hideHistory, Boolean skipPush)
Adds members to a given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.memberIds- The list of the member ids to be added.systemMessage- The system message that will be shown in the channel.hideHistory- Hides the history of the channel to the added member.skipPush- If true, skips sending push notifications.- Returns:
Executable async Call responsible for adding the members.
-
addMembers
@CheckResult() final Call<Channel> addMembers(String channelType, String channelId, AddMembersParams params)
Adds members to a given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.params- The AddMembersParams holding data about the members to be added.- Returns:
Executable async Call responsible for adding the members.
-
removeMembers
@CheckResult() final Call<Channel> removeMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean skipPush)
Removes members from a given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.memberIds- The list of the member ids to be removed.systemMessage- The system message that will be shown in the channel.skipPush- If true, skips sending push notifications.- Returns:
Executable async Call responsible for removing the members.
-
inviteMembers
@CheckResult() final Call<Channel> inviteMembers(String channelType, String channelId, List<String> memberIds, Message systemMessage, Boolean skipPush)
Invites members to a given channel.
- Parameters:
channelType- The channel type.channelId- The channel id.memberIds- The list of the member ids to be invited.systemMessage- The system message that will be shown in the channel.skipPush- If true, skips sending push notifications.- Returns:
Executable async Call responsible for inviting the members.
-
muteChannel
@JvmOverloads()@CheckResult() final Call<Unit> muteChannel(String channelType, String channelId, Integer expiration)
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_updatedevent.- Parameters:
channelType- The channel type.channelId- The channel id.expiration- The duration of mute in millis.- Returns:
Executable async Call responsible for muting a channel.
-
muteChannel
@JvmOverloads()@CheckResult() final Call<Unit> muteChannel(String channelType, String channelId)
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_updatedevent.- Parameters:
channelType- The channel type.channelId- The channel id.- Returns:
Executable async Call responsible for muting a channel.
-
unmuteChannel
@CheckResult() final Call<Unit> unmuteChannel(String channelType, String channelId)
Unmutes a channel for the current user. Triggers
notification.channel_mutes_updatedevent.- Parameters:
channelType- The channel type.channelId- The channel id.- Returns:
Executable async Call responsible for unmuting a channel.
-
muteUser
@JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId, Integer timeout)
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_updatedevent.- Parameters:
userId- The user id to mute.timeout- The timeout in minutes until the mute is expired.- Returns:
Executable async Call responsible for muting a user.
-
muteUser
@JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId)
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_updatedevent.- Parameters:
userId- The user id to mute.- Returns:
Executable async Call responsible for muting a user.
-
unmuteUser
@CheckResult() final Call<Unit> unmuteUser(String userId)
Unmutes a previously muted user. Triggers
notification.mutes_updatedevent.- Parameters:
userId- The user id to unmute.- Returns:
Executable async Call responsible for unmuting a user.
-
unmuteCurrentUser
@CheckResult() final Call<Unit> unmuteCurrentUser()
-
muteCurrentUser
@CheckResult() final Call<Mute> muteCurrentUser()
-
flagUser
@CheckResult() final Call<Flag> flagUser(String userId, String reason, Map<String, String> customData)
Flags a user.
- Parameters:
userId- The ID of the user to flag.reason- The (optional) reason for flagging the user.customData- Custom data to be attached to the flag.
-
unflagUser
@CheckResult() final Call<Flag> unflagUser(String userId)
Un-flags a previously flagged user.
- Parameters:
userId- The ID of the user to un-flag.
-
flagMessage
@CheckResult() final Call<Flag> flagMessage(String messageId, String reason, Map<String, String> customData)
Flags a message.
- Parameters:
messageId- The ID of the message to flag.reason- The (optional) reason for flagging the message.customData- Custom data to be attached to the flag.
-
unflagMessage
@CheckResult() final Call<Flag> unflagMessage(String messageId)
Un-flags a previously flagged message.
- Parameters:
messageId- The ID of the message to un-flag.
-
translate
@CheckResult() final Call<Message> translate(String messageId, String language)
Translate a message.
- Parameters:
messageId- The ID of the message to translate.language- The language to translate the message to.
-
enrichUrl
@CheckResult() final Call<Attachment> enrichUrl(String url)
Enriches the given URL with Open Graph data.
-
banUser
@CheckResult() final Call<Unit> banUser(String targetId, String channelType, String channelId, String reason, Integer timeout)
Bans a user from a given channel.
- Parameters:
targetId- The ID of the user to ban.channelType- The type of the channel.channelId- The ID of the channel.reason- The (optional) reason for banning the user.timeout- The (optional) duration of the ban in minutes.
-
unbanUser
@CheckResult() final Call<Unit> unbanUser(String targetId, String channelType, String channelId)
Unbans a user from a given channel.
- Parameters:
targetId- The ID of the user to unban.channelType- The type of the channel.channelId- The ID of the channel.
-
shadowBanUser
@CheckResult() final Call<Unit> shadowBanUser(String targetId, String channelType, String channelId, String reason, Integer timeout)
Shadow bans a user from a given channel.
- Parameters:
targetId- The ID of the user to shadow ban.channelType- The type of the channel.channelId- The ID of the channel.reason- The (optional) reason for shadow banning the user.timeout- The (optional) duration of the shadow ban in minutes.
-
removeShadowBan
@CheckResult() final Call<Unit> removeShadowBan(String targetId, String channelType, String channelId)
Removes a shadow ban from a user in a given channel.
- Parameters:
targetId- The ID of the user to un-shadow ban.channelType- The type of the channel.channelId- The ID of the channel.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore, Date createdAtBeforeOrEqual)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.limit- The maximum number of banned users to return.createdAtAfter- The date after which the ban was created.createdAtAfterOrEqual- The date after (or at) which the ban was created.createdAtBefore- The date before which the ban was created.createdAtBeforeOrEqual- The date before (or at) which the ban was created.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.limit- The maximum number of banned users to return.createdAtAfter- The date after which the ban was created.createdAtAfterOrEqual- The date after (or at) which the ban was created.createdAtBefore- The date before which the ban was created.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.limit- The maximum number of banned users to return.createdAtAfter- The date after which the ban was created.createdAtAfterOrEqual- The date after (or at) which the ban was created.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.limit- The maximum number of banned users to return.createdAtAfter- The date after which the ban was created.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.limit- The maximum number of banned users to return.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.offset- The offset to start from.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.sort- The sorter object to apply to the query.
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter)
Queries the banned users matching the provided filters.
- Parameters:
filter- The filter object to apply to the query.
-
setPushNotificationReceivedListener
final Unit setPushNotificationReceivedListener(PushNotificationReceivedListener pushNotificationReceivedListener)
-
getConnectionId
final String getConnectionId()
-
getCurrentUser
final User getCurrentUser()
-
getCurrentOrStoredUserId
final String getCurrentOrStoredUserId()
-
getCurrentToken
final String getCurrentToken()
Retrieves the current user token (or null if it doesn't exist).
-
getAppSettings
final AppSettings getAppSettings()
Returns application settings from the server or the default ones as a fallback.
- Returns:
The application settings.
-
isSocketConnected
final Boolean isSocketConnected()
Checks if the chat socket is connected.
-
channel
final ChannelClient channel(String channelType, String channelId)
Returns a ChannelClient for given type and id.
- Parameters:
channelType- The channel type.channelId- The channel id.
-
channel
final ChannelClient channel(String cid)
Returns a ChannelClient for given cid.
- Parameters:
cid- The full channel id.
-
createChannel
@CheckResult() final Call<Channel> createChannel(String channelType, String channelId, List<String> memberIds, Map<String, Object> extraData)
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.
The call will be retried accordingly to retryPolicy.
- Parameters:
channelType- The channel type.channelId- The channel id.memberIds- The list of members' ids.extraData- Map of key-value pairs that let you store extra data.- Returns:
Executable async Call responsible for creating the channel.
-
createChannel
@CheckResult() final Call<Channel> createChannel(String channelType, String channelId, CreateChannelParams params)
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.
The call will be retried accordingly to retryPolicy.
- Parameters:
channelType- The channel type.channelId- The channel id.params- The CreateChannelParams holding the data required for creating a channel.- Returns:
Executable async Call responsible for creating the channel.
-
getSyncHistory
@CheckResult() final Call<List<ChatEvent>> getSyncHistory(List<String> channelsIds, Date lastSyncAt)
Returns all events that happened for a list of channels since last sync (while the user was not connected to the web-socket).
- Parameters:
channelsIds- The list of channel CIDs.lastSyncAt- The last time the user was online and in sync.- Returns:
Executable async Call responsible for obtaining missing events.
-
getSyncHistory
@CheckResult() final Call<List<ChatEvent>> getSyncHistory(List<String> channelsIds, String lastSyncAt)
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.
- Parameters:
channelsIds- The list of channel CIDs.lastSyncAt- The last time the user was online and in sync.- Returns:
Executable async Call responsible for obtaining missing events.
-
keystroke
@CheckResult() final Call<ChatEvent> keystroke(String channelType, String channelId, String parentId)
Sends a EventType.TYPING_START event to the backend.
- Parameters:
channelType- The type of this channel i.e.channelId- The id of this channel.parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.- Returns:
Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.
-
stopTyping
@CheckResult() final Call<ChatEvent> stopTyping(String channelType, String channelId, String parentId)
Sends a EventType.TYPING_STOP event to the backend.
- Parameters:
channelType- The type of this channel i.e.channelId- The id of this channel.parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.- Returns:
Executable async Call which completes with Result having ChatEvent data if successful or Error if fails.
-
createVideoCall
@Deprecated(message = "This third-party library integration is deprecated. Contact the support team for more information.", level = DeprecationLevel.WARNING)@CheckResult() final Call<VideoCallInfo> createVideoCall(String channelType, String channelId, String callType, String callId)
Creates a newly available video call, which belongs to a channel. The video call will be created based on the third-party video integration (Agora and 100ms) on your Stream Dashboard.
You can set the call type by passing callType like
videooraudio.- Parameters:
channelType- The channel type.channelId- The id of the channel.callType- Represents call type such asvideooraudio.callId- A unique identifier to assign to the call.
-
getVideoCallToken
@Deprecated(message = "This third-party library integration is deprecated. Contact the support team for more information.", level = DeprecationLevel.WARNING)@CheckResult() final Call<VideoCallToken> getVideoCallToken(String callId)
Returns the currently available video call token.
- Parameters:
callId- The call id, which indicates a dedicated video call id on the channel.
-
downloadFile
@CheckResult() final Call<ResponseBody> downloadFile(String fileUrl)
Downloads the given file which can be fetched through the response body.
- Parameters:
fileUrl- The URL of the file that we are downloading.- Returns:
A Retrofit ResponseBody wrapped inside a Call.
-
queryThreads
@CheckResult() final Call<List<Thread>> queryThreads(QueryThreadsRequest query)
Query threads matching query request.
- Parameters:
query- QueryThreadsRequest with query parameters to get matching users.
-
queryThreadsResult
@CheckResult() final Call<QueryThreadsResult> queryThreadsResult(QueryThreadsRequest query)
Query threads matching query request.
- Parameters:
query- QueryThreadsRequest with query parameters to get matching users.
-
getThread
@CheckResult() final Call<Thread> getThread(String messageId, GetThreadOptions options)
Get a thread by message id.
- Parameters:
messageId- The message id.options- The query options.
-
partialUpdateThread
@CheckResult() final Call<Thread> partialUpdateThread(String messageId, Map<String, Object> set, List<String> unset)
Partially updates specific Thread fields retaining the fields which were set previously.
- Parameters:
messageId- The message ID.set- The key-value data which will be added to the existing message object.unset- The list of fields which will be removed from the existing message object.- Returns:
Executable async Call responsible for partially updating the message.
-
createReminder
@CheckResult() final Call<MessageReminder> createReminder(String messageId, Date remindAt)
Creates a reminder for a message.
- Parameters:
messageId- The message id.remindAt- The date when the reminder should be triggered.- Returns:
Executable async Call responsible for creating the reminder.
-
updateReminder
@CheckResult() final Call<MessageReminder> updateReminder(String messageId, Date remindAt)
Updates an existing reminder for a message.
- Parameters:
messageId- The message id.remindAt- The date when the reminder should be triggered.- Returns:
Executable async Call responsible for updating the reminder.
-
deleteReminder
@CheckResult() final Call<Unit> deleteReminder(String messageId)
Deletes a reminder for a message.
- Parameters:
messageId- The message id whose reminder should be deleted.- Returns:
Executable async Call responsible for deleting the reminder.
-
queryReminders
@CheckResult() final Call<QueryRemindersResult> queryReminders(FilterObject filter, Integer limit, String next, QuerySorter<MessageReminder> sort)
Queries the message reminders for the current user matching the provided filters.
- Parameters:
filter- The FilterObject to filter the reminders.limit- The maximum number of reminders to return.next- The pagination token for the next page of results.sort- The sorter object to apply to the query.- Returns:
Executable async Call responsible for obtaining the message reminders.
-
devToken
final String devToken(String userId)
Generate a developer token that can be used to connect users while the app is using a development environment.
- Parameters:
userId- the desired id of the user to be connected.
-
instance
final static ChatClient instance()
-
handlePushMessage
@JvmOverloads() final static Unit handlePushMessage(PushMessage pushMessage)
Handles push message. If user is not connected - automatically restores last user credentials and sets user without connecting to the socket. Push message will be handled internally unless user overrides NotificationHandler.onPushMessage Be sure to initialize ChatClient before calling this method!
- Parameters:
pushMessage- The push message to handle.
-
-
-
-