SendbirdChat class

An object represents a main class to use Sendbird Chat

Constructors

SendbirdChat()
factory

Properties

chat → Chat
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

currentUser User?
The current connected User. null if connect is not called.
no setter
getSubscribedCustomTypeTotalUnreadMessageCount int
Gets the total number of unread message of GroupChannels with subscribed custom types.
no setter
getSubscribedTotalUnreadMessageCount int
Gets the subscribed total number of unread message of all GroupChannels the current user has joined.
no setter
maxInt int
Max int value
no setter

Static Methods

addChannelHandler(String identifier, RootChannelHandler handler) → void
Adds a channel handler. All added handlers will be notified when events occur.
addConnectionHandler(String identifier, ConnectionHandler handler) → void
Adds a connection handler. All added handlers will be notified when events occurs.
addExtension(String key, String version) → void
To send additional User-Agent information please set the version information. This will be set pre-defined keys only.
addUserEventHandler(String identifier, UserEventHandler handler) → void
Adds a user event handler. All added handlers will be notified when events occur.
authenticateFeed(String userId, {String? accessToken, String? apiHost}) Future<User>
Authenticate with the Sendbird server. Calling this method will grant you access to Sendbird notification's features. If you want to access Sendbird Chat's features, call SendbirdChat.connect. You can deauthenticate from the Sendbird server by calling SendbirdChat.disconnect. @since 4.0.6
blockUser(String userId) Future<User>
Blocks the specified User ID. Blocked User cannot send messages to the blocker.
clearCachedData() Future<void>
Clears all cached data. Refer to SendbirdChatOptions.useCollectionCaching. @since 4.2.0
clearCachedMessages(String channelUrl) Future<void>
Clears cached messages regarding channelUrl. Refer to SendbirdChatOptions.useCollectionCaching. @since 4.2.0
connect(String userId, {String? nickname, String? accessToken, String? apiHost, String? wsHost}) Future<User>
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.
disconnect() Future<void>
Disconnects from SendbirdChat.
getAllEmoji() Future<EmojiContainer>
Requests the all emoji.
getAppInfo() AppInfo?
Returns current application information with AppInfo.
getApplicationId() String?
Returns current application id.
getCachedDataSize() Future<int?>
Gets cached data size. (Bytes) Refer to SendbirdChatOptions.useCollectionCaching. @since 4.2.0
getChannelHandler(String identifier) BaseChannelHandler?
Gets a channel handler.
getChannelInvitationPreference() Future<bool>
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 GroupChannelOperation.acceptInvitation or decline the invitation by calling GroupChannelOperation.declineInvitation.
getConnectionHandler(String identifier) ConnectionHandler?
Gets a connection handler.
getConnectionState() MyConnectionState
Gets the SDK socket connection state.
getDoNotDisturb() Future<DoNotDisturb>
Gets Do-not-disturb option for the current User.
getEmoji(String key) Future<Emoji>
Requests the emoji.
getEmojiCategory(int categoryId) Future<EmojiCategory>
Requests the emoji category.
getGlobalNotificationChannelSetting() Future<GlobalNotificationChannelSetting>
Retrieves Global Notification channel theme. @since 4.0.3
getGroupChannelCount(MyMemberStateFilter filter) Future<int>
Gets the number of my GroupChannels.
getLastConnectedAt() int?
The last connected timestamp.
getMyFeedChannelChangeLogs(FeedChannelChangeLogsParams params, {String? token, int? timestamp}) Future<FeedChannelChangeLogs>
Requests the channel changelogs from given token. @since 4.0.3
getMyGroupChannelChangeLogs(GroupChannelChangeLogsParams params, {String? token, int? timestamp}) Future<GroupChannelChangeLogs>
Requests the channel changelogs from given token.
getNotificationTemplate({required String key}) Future<NotificationTemplate>
Retrieves Notification template. key is the template key. @since 4.0.3
getNotificationTemplateListByToken(NotificationTemplateListParams params, {String? token}) Future<NotificationTemplateList>
Retrieves Notification template list by token. token is the value to retrieve notification template list from. @since 4.0.3
getOptions() SendbirdChatOptions
Returns current SendbirdChatOptions.
getPendingPushToken() String?
The pending push token. null if there is no registration pending token.
getPushSound() Future<String>
Gets push notification sound path for the current User.
getPushTemplate() Future<String>
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.
getPushTriggerOption() Future<PushTriggerOption>
Gets the current User's push trigger option. Refer to PushTriggerOption. For details of push trigger option, refer to setPushTriggerOption.
getSdkVersion() String
Current SDK version.
getSessionHandler() SessionHandler?
Gets a session handler.
getSnoozePeriod() Future<SnoozePeriod>
Gets snooze period for the current User.
getSubscribedCustomTypeUnreadMessageCount(String customType) int?
Gets the number of unread message of GroupChannel with subscribed custom type.
getTotalScheduledMessageCount({TotalScheduledMessageCountParams? params}) Future<int>
Gets the number of total scheduled messages.
getTotalUnreadChannelCount([GroupChannelTotalUnreadChannelCountParams? params]) Future<int>
Gets the total number of unread GroupChannels the current user has joined.
getTotalUnreadMessageCount([GroupChannelTotalUnreadMessageCountParams? params]) Future<int>
Gets the total number of unread message of GroupChannels with GroupChannelTotalUnreadMessageCountParams filter.
getTotalUnreadMessageCountWithFeedChannel([GroupChannelTotalUnreadMessageCountParams? params]) Future<UnreadMessageCount>
Gets the total number of unread message of GroupChannels and FeedChannels with GroupChannelTotalUnreadMessageCountParams filter. @since 4.0.3
getUnreadItemCount(List<UnreadItemKey> keys) Future<GroupChannelUnreadItemCount>
Gets the unread item count of GroupChannels from keys.
getUserEventHandler(String identifier) UserEventHandler?
Gets a user event handler.
init({required String appId, SendbirdChatOptions? options}) Future<bool>
Initializes SendbirdChat with given app ID.
isInitialized() bool
True if SDK has been initialized.
markAsDelivered({required Map<String, dynamic> data}) Future<void>
Sends mark as delivered to this channel when you received push message from us. data is the payload data from the push. Delivery receipt is a premium feature.
markAsRead({required List<String> channelUrls}) Future<void>
Sends mark as read to joined GroupChannels. This method has rate limit. You can send one request per second.
markAsReadAll() Future<void>
Sends mark as read to all joined GroupChannels. This method has rate limit. You can send one request per second.
reconnect() Future<bool>
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.
refreshNotificationCollections() → void
Refresh the contents of all notification collections that are currently valid. @since 4.0.6
registerPushToken({required PushTokenType type, required String token, bool alwaysPush = false, bool unique = false}) Future<PushTokenRegistrationStatus>
Registers push token for the current User to receive push notification. To enable push notification and get a token, 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 SendbirdChat.registerPushToken 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.
removeAllChannelHandlers() → void
Removes all channel handlers added by addChannelHandler.
removeAllConnectionHandlers() → void
Removes all connection handlers added by addConnectionHandler.
removeAllUserEventHandlers() → void
Removes all user event handlers added by addUserEventHandler.
removeChannelHandler(String identifier) → void
Removes a channel handler. The deleted handler no longer be notified.
removeConnectionHandler(String identifier) → void
Removes a connection handler. The deleted handler no longer be notified.
removeSessionHandler() → void
Removes a session handler. The deleted handler no longer be notified.
removeUserEventHandler(String identifier) → void
Removes a user event handler. The deleted handler no longer be notified.
setAppVersion(String version) → void
Sets app version.
setChannelInvitationPreference(bool autoAccept) Future<void>
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 GroupChannelOperation.acceptInvitation or decline the invitation by calling GroupChannelOperation.declineInvitation.
setDoNotDisturb({required bool enable, int startHour = 0, int startMin = 0, int endHour = 23, int endMin = 59, String timezone = 'UTC'}) Future<void>
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.
setLogLevel(LogLevel level) → void
Sets log level.
setOptions(SendbirdChatOptions options) → void
Sets SendbirdChatOptions.
setPushSound(String sound) Future<void>
Sets the push notification sound file path for the current User. This setting will be delivered on push notification payload.
setPushTemplate(String name) Future<void>
Sets push template option for the current User. The only valid arguments for template name are SendbirdChat.pushTemplateDefault and SendbirdChat.pushTemplateAlternative. If SendbirdChat.pushTemplateDefault is set, the push notification will contain the original message in the message field of the push notification. If SendbirdChat.pushTemplateAlternative is set, message of push notification will be replaced by the content you've set on Sendbird Dashboard.
setPushTriggerOption(PushTriggerOption option) Future<void>
Sets the current User's push trigger option. If certain channel's push trigger option is set to GroupChannelPushTriggerOption.defaultValue, it works according to the state of PushTriggerOption. If not, push messages will be triggered according to the state of GroupChannelPushTriggerOption. Refer to GroupChannelPushTriggerOption.
setSessionHandler(SessionHandler handler) → void
Set a SessionHandler which is required for SDK refresh the session when the current session expires. Must be set before the connection is made by connect.
setSnoozePeriod({required bool enable, DateTime? startDate, DateTime? endDate}) Future<void>
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.
unblockUser(String userId) Future<void>
Unblocks the specified User ID. Unblocked User cannot send messages to the ex-blocker.
unregisterPushToken({required PushTokenType type, required String token}) Future<void>
Unregisters push token for the current User.
unregisterPushTokenAll() Future<void>
Unregisters all push token bound to the current User.
updateCurrentUserInfo({String? nickname, FileInfo? profileFileInfo, List<String>? preferredLanguages, ProgressHandler? progressHandler}) Future<void>
Updates current User's information.

Constants

pushTemplateAlternative → const String
Alternative push template
pushTemplateDefault → const String
Default push template