SendbirdChat class
An object represents a main class to use Sendbird Chat
Constructors
- SendbirdChat()
-
factory
Properties
- chat → Chat
-
read-only
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
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.read-only - getSubscribedCustomTypeTotalUnreadMessageCount → int
-
Gets the total number of unread message of
GroupChannel
s with subscribed custom types.read-only - getSubscribedTotalUnreadMessageCount → int
-
Gets the subscribed total number of unread message of all
GroupChannel
s the current user has joined.read-only
Static Methods
-
addChannelHandler(
String identifier, BaseChannelHandler 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.
-
blockUser(
String userId) → Future< User> -
Blocks the specified
User
ID. BlockedUser
cannot send messages to the blocker. -
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 createdUser
s without auth token, refer to connect or just pass auth token withnull
. -
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.
-
getChannelHandler(
String identifier) → BaseChannelHandler? - Gets a channel handler.
-
getChannelInvitationPreference(
) → Future< bool> -
Gets the current
User
's preference forGroupChannel
join. If this is set astrue
, theUser
will automatically join theGroupChannel
. If set asfalse
, theUser
can join theGroupChannel
by callingGroupChannelOperation.acceptInvitation
or decline the invitation by callingGroupChannelOperation.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.
-
getGroupChannelCount(
MyMemberStateFilter filter) → Future< int> -
Gets the number of my
GroupChannel
s. -
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.1
-
getMyGroupChannelChangeLogs(
GroupChannelChangeLogsParams params, {String? token, int? timestamp}) → Future< GroupChannelChangeLogs> - Requests the channel changelogs from given token.
-
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 toPushTriggerOption
. 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
GroupChannel
s the current user has joined. -
getTotalUnreadMessageCount(
[GroupChannelTotalUnreadMessageCountParams? params]) → Future< int> -
Gets the total number of unread message of
GroupChannel
s with GroupChannelTotalUnreadMessageCountParams filter. -
getTotalUnreadMessageCountWithFeedChannel(
[GroupChannelTotalUnreadMessageCountParams? params]) → Future< UnreadMessageCount> -
Gets the total number of unread message of
GroupChannel
s andFeedChannel
s with GroupChannelTotalUnreadMessageCountParams filter. @since 4.0.1 -
getUnreadItemCount(
List< UnreadItemKey> keys) → Future<GroupChannelUnreadItemCount> -
Gets the unread item count of
GroupChannel
s from keys. -
getUserEventHandler(
String identifier) → UserEventHandler? - Gets a user event handler.
-
init(
{required String appId, SendbirdChatOptions? options}) → void - 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. -
markAsRead(
{required List< String> channelUrls}) → Future<void> -
Sends mark as read to joined
GroupChannel
s. This method has rate limit. You can send one request per second. -
markAsReadAll(
) → Future< void> -
Sends mark as read to all joined
GroupChannel
s. 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.
-
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 forGroupChannel
join. If this is set astrue
, theUser
will automatically join theGroupChannel
. If set asfalse
, theUser
can join theGroupChannel
by callingGroupChannelOperation.acceptInvitation
or decline the invitation by callingGroupChannelOperation.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 currentUser
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 themessage
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 currentUser
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. UnblockedUser
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
'alternative'
- pushTemplateDefault → const String
-
Default push template
'default'