SendbirdChat

object SendbirdChat

SendbirdChat Main Class.

Types

Link copied to clipboard
object HMS

Push token related class specifically for Huawei Message Service, HMS.

Link copied to clipboard
object Options

Represents operation options.

Link copied to clipboard
enum PushTriggerOption : Enum<SendbirdChat.PushTriggerOption>

PushTriggerOption of the current User. Refer to setPushTriggerOption.

Functions

Link copied to clipboard
fun addChannelHandler(identifier: String, handler: BaseChannelHandler)

Adds a channel handler. All added handlers will be notified when events occur.

Link copied to clipboard
fun addConnectionHandler(identifier: String, handler: ConnectionHandler)

Adds a connection handler. All added handlers will be notified when events occurs.

Link copied to clipboard
fun addExtension(key: String, version: String)

To send additional User-Agent information please set the version information. This will be set pre-defined keys only.

Link copied to clipboard
fun addFriends(userIds: List<String>, handler: UsersHandler?)

Add friends.

Link copied to clipboard
fun addSendbirdExtensions(extensions: List<SendbirdSdkInfo>, customData: Map<String, String>? = null): Boolean

Internal purpose. DO NOT USE it for customers.

Link copied to clipboard
fun addUserEventHandler(identifier: String, handler: UserEventHandler)

Adds a user event handler. All added handlers will be notified when events occur.

Link copied to clipboard
fun allowFriendDiscovery(allow: Boolean, handler: CompletionHandler?)

Sets friend discoverability of current user.

Link copied to clipboard
fun authenticateFeed(userId: String, authToken: String? = null, handler: AuthenticationHandler?)
fun authenticateFeed(userId: String, authToken: String? = null, apiHost: String?, handler: AuthenticationHandler?)

If you want to use the interface provided by the FeedChannel only, we'd recommend to authenticate using this function instead of SendbirdChat.connect.

Link copied to clipboard
fun blockUser(userToBlock: User, handler: UserHandler?)

Blocks the specified User. Blocked User cannot send messages to the blocker.

fun blockUser(userIdToBlock: String, handler: UserHandler?)

Blocks the specified User ID. Blocked User cannot send messages to the blocker.

Link copied to clipboard
fun clearCachedData(context: Context, handler: CompletionHandler?)

Clears the db data used in local caching.

Link copied to clipboard
fun clearCachedMessages(channelUrl: String, handler: CompletionHandler?)

Clear cached messages of specific channel.

Link copied to clipboard
fun connect(userId: String, authToken: String? = null, handler: ConnectHandler?)
fun connect(userId: String, authToken: String?, apiHost: String?, wsHost: String?, handler: ConnectHandler?)

Connects to SendbirdChat with given User ID and auth token. If you have created Users without auth token, refer to connect or just pass auth token with null.

Link copied to clipboard

Creates a query instance to get the whole User list.

Link copied to clipboard

Creates a query instance to get the banned user list from this channel.

Link copied to clipboard

Creates a query instance to get only the blocked User (by me) list.

Link copied to clipboard
fun createFriendListQuery(params: FriendListQueryParams): FriendListQuery

Creates a query instance to get friends.

Link copied to clipboard

Creates GroupChannelCollection instance with the params.

Link copied to clipboard

Creates MessageCollection instance with the params.

Link copied to clipboard

Creates a query instance to search for a message.

Link copied to clipboard

Creates a query instance to get the muted user (online and offline both) list of the channel.

Link copied to clipboard

Creates a query instance to get FeedChannels the current User has joined.

Link copied to clipboard

Creates a query instance to get the operator list from the channel.

Link copied to clipboard

Creates a query instance to get the whole participant list (online only) of the channel.

Link copied to clipboard

Creates a query to get pinned messages.

Link copied to clipboard
fun createPollListQuery(params: PollListQueryParams): PollListQuery

Creates a query instance to get the poll list from the channel.

Link copied to clipboard

Creates a query instance to get the voters of a poll option.

Link copied to clipboard

Creates a query instance to get the Scheduled Message list.

Link copied to clipboard
fun deleteFriend(userId: String, handler: CompletionHandler?)

Delete friend.

Link copied to clipboard
fun deleteFriendDiscoveries(discoveryKeys: List<String>, handler: CompletionHandler?)

Delete friend discoveries.

Link copied to clipboard
fun deleteFriendDiscovery(discoveryKey: String, handler: CompletionHandler?)

Delete friend discovery.

Link copied to clipboard
fun deleteFriends(userIds: List<String>, handler: CompletionHandler?)

Delete friends.

Link copied to clipboard
fun disconnect(handler: DisconnectHandler?)

Disconnects from SendbirdChat.

Link copied to clipboard
fun disconnectWebSocket(handler: DisconnectHandler?)

Disconnects the websocket connection only. This does not clear the currentUser and any cached data. If you want to logout, call disconnect.

Link copied to clipboard
fun getAllEmoji(handler: AllEmojiHandler?)

Requests the all emoji. The result is passed to handler.

Link copied to clipboard
fun getAllowFriendDiscovery(handler: GetAllowFriendDiscoveryHandler?)

Gets friend discoverability of current user.

Link copied to clipboard
fun getCachedDataSize(context: Context): Long

Gets the size of cached data. If local caching is not used, return 0 If you want to clear all cached data, call SendbirdChat.clearCachedData If you want to clear specific channel's cache, call SendbirdChat.clearCachedMessages

Link copied to clipboard

Gets the current User's preference for GroupChannel join. If this is set as true, the User will automatically join the GroupChannel. If set as false, the User can join the GroupChannel by calling GroupChannel.acceptInvitation or decline the invitation by calling GroupChannel.declineInvitation.

Link copied to clipboard
fun getDoNotDisturb(handler: DoNotDisturbHandler?)

Gets Do-not-disturb option for the current User.

Link copied to clipboard
fun getEmoji(key: String, handler: EmojiHandler?)

Requests the emoji. The result is passed to handler.

Link copied to clipboard
fun getEmojiCategory(emojiCategoryId: Long, handler: EmojiCategoryHandler?)

Requests the emoji category. The result is passed to handler.

Link copied to clipboard
fun getFriendChangeLogsByToken(token: String?, handler: FriendChangeLogsByTokenHandler?)

Get friend changelogs by token.

Link copied to clipboard

Retrieves Global Notification channel theme.

Link copied to clipboard
fun getGroupChannelCount(myMemberStateFilter: MyMemberStateFilter?, handler: CountHandler?)

Gets the number of my GroupChannels.

Link copied to clipboard
fun getMembersChangeLogsByToken(token: String, handler: MembersChangeLogsHandler?)

Requests the changelogs of members of group channels the current user is joined in.

Link copied to clipboard
fun getMembersChangeLogsByTs(ts: Long, handler: MembersChangeLogsHandler?)

Requests the changelogs of members of group channels the current user is joined in.

Link copied to clipboard
fun getMyFeedChannelChangeLogsByTimestamp(ts: Long, params: FeedChannelChangeLogsParams = FeedChannelChangeLogsParams(), handler: FeedChannelChangeLogsHandler?)

Requests the channel changelogs after given timestamp. The result is passed to handler.

Link copied to clipboard
fun getMyFeedChannelChangeLogsByToken(token: String?, params: FeedChannelChangeLogsParams = FeedChannelChangeLogsParams(), handler: FeedChannelChangeLogsHandler?)

Requests the channel changelogs from given token. The result is passed to handler.

Link copied to clipboard
fun getMyGroupChannelChangeLogsByTimestamp(ts: Long, params: GroupChannelChangeLogsParams = GroupChannelChangeLogsParams(), handler: GroupChannelChangeLogsHandler?)

Requests the channel changelogs after given timestamp. The result is passed to handler.

Link copied to clipboard
fun getMyGroupChannelChangeLogsByToken(token: String?, params: GroupChannelChangeLogsParams = GroupChannelChangeLogsParams(), handler: GroupChannelChangeLogsHandler?)

Requests the channel changelogs from given token. The result is passed to handler.

Link copied to clipboard
fun getMyPushTokensByToken(token: String?, type: PushTokenType, handler: PushTokensHandler?)

Requests push tokens of current user from given token. The result is passed to handler.

Link copied to clipboard
fun getNotificationTemplate(key: String, handler: NotificationTemplateHandler?)

Retrieves Notification template

Link copied to clipboard
fun getNotificationTemplateListByToken(token: String?, params: NotificationTemplateListParams = NotificationTemplateListParams(), handler: NotificationTemplateListHandler?)

Retrieves Notification template list by token

Link copied to clipboard
fun getPushSound(handler: PushSoundHandler?)

Gets push notification sound path for the current User.

Link copied to clipboard
fun getPushTemplate(handler: PushTemplateHandler?)

Gets push template option for the current User. For details of push template option, refer to setPushTemplate. This can be used, for instance, when you need to check the push notification content preview is on or off at the moment.

Link copied to clipboard
fun getPushTriggerOption(handler: PushTriggerOptionHandler?)

Gets the current User's push trigger option. Refer to PushTriggerOption. For details of push trigger option, refer to setPushTriggerOption.

Link copied to clipboard
fun getSnoozePeriod(handler: SnoozePeriodHandler?)

Gets snooze period for the current User.

Gets the total number of unread message of GroupChannels with subscribed custom types.

fun getSubscribedCustomTypeUnreadMessageCount(customType: String?): Int

Gets the number of unread message of GroupChannel with subscribed custom type.

Link copied to clipboard
fun getSubscribedTotalUnreadMessageCount(): Int

Gets the subscribed total number of unread message of all GroupChannels the current user has joined.

Link copied to clipboard

Gets the number of total scheduled messages.

Link copied to clipboard
fun getTotalUnreadChannelCount(params: GroupChannelTotalUnreadChannelCountParams = GroupChannelTotalUnreadChannelCountParams(), handler: CountHandler?)

Gets the total number of unread GroupChannels the current user has joined.

Link copied to clipboard
fun getTotalUnreadMessageCount(params: GroupChannelTotalUnreadMessageCountParams = GroupChannelTotalUnreadMessageCountParams(), handler: CountHandler?)
fun getTotalUnreadMessageCount(params: GroupChannelTotalUnreadMessageCountParams = GroupChannelTotalUnreadMessageCountParams(), handler: UnreadMessageCountHandler?)

Gets the total number of unread message of GroupChannels with GroupChannelTotalUnreadMessageCountParams filter.

Link copied to clipboard
fun getUIKitConfiguration(handler: UIKitConfigurationHandler?)
Link copied to clipboard

Gets the unread item count of GroupChannels from keys.

Link copied to clipboard
fun getUnreadMessageCount(): UnreadMessageCount

Gets the subscribed total unread message of current user.

Link copied to clipboard
fun init(initParams: InitParams, handler: InitResultHandler)

Initializes SendbirdChat with given app ID.

Link copied to clipboard
fun markAsDelivered(data: Map<String, String>, completionHandler: CompletionHandler? = null)

Sends mark as delivered to this channel when you received push message from us.

Link copied to clipboard
fun markAsRead(channelUrls: List<String>, handler: CompletionHandler?)

Sends mark as read to joined GroupChannels. This method has rate limit. You can send one request per second. It returns SendbirdException if you exceed the rate limit.

Link copied to clipboard
fun markAsReadAll(handler: CompletionHandler?)

Sends mark as read to all joined GroupChannels. This method has rate limit. You can send one request per second. It returns SendbirdException if you exceed the rate limit.

Link copied to clipboard
fun reconnect(): Boolean

Tries reconnection with previously and successfully connected user information. This can be called in ConnectionHandler.onReconnectFailed or where you check the device network status to let the SDK try reconnection. ConnectionHandler.onReconnectStarted will be called after you call this (note that it will not be called if there is previously started connection process which has not finished), and ConnectionHandler.onReconnectFailed or ConnectionHandler.onReconnectSucceeded will be called according to the connection status afterwards.

Usually, the SDK automatically retries connection process when the network connection is lost with some backoff period. When you call this method, you can start connection process immediately.

Link copied to clipboard
fun refreshNotificationCollections()

Refreshes the currently active NotificationCollection.

Link copied to clipboard
fun registerPushToken(gcmRegToken: String, handler: PushTokenWithStatusHandler?)

Registers push token for the current User to receive push notification. To enable push notification and get a token, refer to Sendbird Docs.

Push token registration succeeds only when the connection (connect) is made. Otherwise, callback will return with PushTokenRegistrationStatus.PENDING status. Then you can register push token again by calling this method with pushToken which is provided by FCM as the token parameter, after the connection is done. This just adds token to the server. If you want to register this token and delete all the previous ones, refer to registerPushToken.

fun registerPushToken(gcmRegToken: String, unique: Boolean, handler: PushTokenWithStatusHandler?)

Registers push token for the current User to receive push notification. To enable push notification and get a token, refer to Sendbird Docs.

Push token registration succeeds only when the connection (connect) is made. Otherwise, callback will return with PushTokenRegistrationStatus.PENDING status. Then, you can register push token again by calling registerPushToken after the connection is done.

Link copied to clipboard
fun removeAllChannelHandlers()

Removes all channel handlers added by addChannelHandler.

Link copied to clipboard
fun removeAllConnectionHandlers()

Removes all connection handlers added by addConnectionHandler.

Link copied to clipboard
fun removeAllUserEventHandlers()

Removes all user event handlers added by addUserEventHandler.

Link copied to clipboard
fun removeChannelHandler(identifier: String): BaseChannelHandler?

Removes a channel handler. The deleted handler no longer be notified.

Link copied to clipboard
fun removeConnectionHandler(identifier: String): ConnectionHandler?

Removes a connection handler. The deleted handler no longer be notified.

Link copied to clipboard
fun removeUserEventHandler(identifier: String): UserEventHandler?

Removes a user event handler. The deleted handler no longer be notified.

Link copied to clipboard
fun setChannelInvitationPreference(autoAccept: Boolean, handler: CompletionHandler?)

Sets the current User's preference for GroupChannel join. If this is set as true, the User will automatically join the GroupChannel. If set as false, the User can join the GroupChannel by calling GroupChannel.acceptInvitation or decline the invitation by calling GroupChannel.declineInvitation.

Link copied to clipboard
fun setDoNotDisturb(doNotDisturbOn: Boolean, startHour: Int, startMin: Int, endHour: Int, endMin: Int, timezone: String, handler: CompletionHandler?)

Sets Do-not-disturb option for the current User. If this option is enabled, the current User does not receive push notification during the specified time repeatedly. If you want to snooze specific period, use setSnoozePeriod.

Link copied to clipboard
fun setPushSound(sound: String, handler: CompletionHandler?)

Sets the push notification sound file path for the current User. This setting will be delivered on push notification payload.

Link copied to clipboard
fun setPushTemplate(templateName: String, handler: CompletionHandler?)

Sets push template option for the current User. The only valid arguments for template name are PUSH_TEMPLATE_DEFAULT and PUSH_TEMPLATE_ALTERNATIVE. If PUSH_TEMPLATE_DEFAULT is set, the push notification will contain the original message in the message field of the push notification. If PUSH_TEMPLATE_ALTERNATIVE is set, message of push notification will be replaced by the content you've set on SendbirdChat Dashboard.

Link copied to clipboard
fun setPushTriggerOption(pushTriggerOption: SendbirdChat.PushTriggerOption, handler: CompletionHandler?)

Sets the current User's push trigger option. If certain channel's push trigger option is set to GroupChannel.PushTriggerOption.DEFAULT, it works according to the state of PushTriggerOption. If not, push messages will be triggered according to the state of GroupChannel.PushTriggerOption. Refer to GroupChannel.PushTriggerOption.

Link copied to clipboard
fun setSessionHandler(sessionHandler: SessionHandler?)

Set a SessionHandler which is required for SDK refresh the session when the current session expires.

Link copied to clipboard
fun setSnoozePeriod(snoozeOn: Boolean, startTs: Long, endTs: Long, handler: CompletionHandler?)

Sets snooze period for the current User. If this option is enabled, the current User does not receive push notification during the given period. It's not a repetitive operation. If you want to snooze repeatedly, use setDoNotDisturb.

Link copied to clipboard
fun unblockUser(blockedUser: User, handler: CompletionHandler?)

Unblocks the specified User. Unblocked User can send messages to the ex-blocker.

fun unblockUser(blockedUserId: String, handler: CompletionHandler?)

Unblocks the specified User ID. Unblocked User cannot send messages to the ex-blocker.

Link copied to clipboard
fun unregisterPushToken(gcmRegToken: String, handler: CompletionHandler?)

Unregisters push token for the current User.

Link copied to clipboard
fun unregisterPushTokenAll(handler: CompletionHandler?)

Unregisters all push token bound to the current User.

Link copied to clipboard
fun updateCurrentUserInfo(params: UserUpdateParams, handler: CompletionHandler?)

Updates current User's information.

fun updateCurrentUserInfo(preferredLanguages: List<String>, handler: CompletionHandler?)
Link copied to clipboard
fun uploadFriendDiscoveries(discoveryMap: Map<String, String>, handler: CompletionHandler?)

Properties

Link copied to clipboard
val appInfo: AppInfo?

Represents information obtained from the application settings.

Link copied to clipboard
val applicationId: String?

Current application ID.

Link copied to clipboard
var autoBackgroundDetection: Boolean

The option to detect if the android.app.Application is in background automatically.

Link copied to clipboard
val connectionState: ConnectionState

Gets the SDK socket connection state.

Link copied to clipboard
val currentUser: User?

The current connected User. null if connect is not called.

Link copied to clipboard
val eKey: String

The key to authenticate the url retrieved from FileMessage.plainUrl, User.plainProfileImageUrl and Thumbnail.plainUrl]. This key has to be put into the HTTP header to access the url provided by above methods.

Link copied to clipboard
val isInitialized: Boolean

A flag indicating whether the SDK is initialized.

Link copied to clipboard
val isUsingLocalCaching: Boolean

Whether the app uses local caching.

Link copied to clipboard
val lastConnectedAt: Long

The last connected timestamp.

Link copied to clipboard
val multipleFilesMessageFileCountLimit: Int

The maximum count of files that can be included in a single com.sendbird.android.message.MultipleFilesMessage.

Link copied to clipboard
var networkAwarenessReconnection: Boolean

The option to reconnect automatically by network awareness. It is true by default.

Link copied to clipboard
val osVersion: String

Current OS version.

Link copied to clipboard
val pendingPushToken: String?

The pending push token. null if there is no registration pending token.

Link copied to clipboard
const val PUSH_TEMPLATE_ALTERNATIVE: String
Link copied to clipboard
const val PUSH_TEMPLATE_DEFAULT: String
Link copied to clipboard
val sdkVersion: String

Current SDK version.