SendbirdChat
public final class SendbirdChat : NSObject
The SendbirdChat
is the core class for Sendbird. This class is singletone instance which is initialized by Application ID.
This class provides the methods for overall operations. The methods include BaseChannelDelegate
registration for receiving events
that are related to channels, ConnectionDelegate
for managing the connection status, updating the current user’s information,
registration for APNS push notification and blocking other users.
-
Gets initializing state.
Declaration
Swift
@objc public static var isInitialized: Bool { get }
Return Value
If
true
,SendbirdChat
instance is initialized. -
Retrieves the SDK version.
Declaration
Swift
@objc public static func getSDKVersion() -> String
Return Value
The SDK version.
-
Gets the Application ID which was used for initialization.
Declaration
Swift
@objc public static func getApplicationId() -> String?
Return Value
The Application ID.
-
Sets the version of the app that uses the Sendbird SDK. The version will be used when the debugging is needed.
Since
3.1.3Declaration
Swift
@objc public static func setAppVersion(version: String?)
Parameters
version
The version of the app.
-
Gets the maximum number of files in a
MultipleFilesMessage
.Since
4.9.1Declaration
Swift
@objc public static func getMultipleFilesMessageFileCountLimit() -> Int
Return Value
multipleFilesMessageFileCountLimit
-
Initializes
SendbirdChat
singleton instance with Sendbird Application ID.The Application ID is on Sendbird dashboard. This method has to be run first in order to user Sendbird.
Since
3.0.227Declaration
Swift
@discardableResult @objc public static func initialize( params: InitParams, migrationStartHandler: VoidHandler? = nil, completionHandler: SBErrorHandler? = nil ) -> Bool
Parameters
params
InitParams
objectmigrationStartHandler
handler that notifies when local cache migration has started
completionHandler
handler that notifies when local cache is ready to use
Return Value
true
if the applicationId is set. -
Synchronously initializes
SendbirdChat
singleton instance with Sendbird Application ID.The Application ID is on Sendbird dashboard. This method has to be run first in order to user Sendbird.
Since
4.0.15Declaration
Swift
@available(*, deprecated, renamed: "initialize(params:migrationStartHandler:completionHandler:﹚", message: "This method is deprecated in 4.15.0. Set `needsSynchronous` in `InitParams` to `true` and use `initialize(params:migrationStartHandler:completionHandler:﹚` instead.") @discardableResult @objc public static func initializeSynchronously(params: InitParams) -> SBError?
Parameters
params
InitParams
objectReturn Value
nil
if the applicationId is set, otherwiseSBError
-
Executes a given handler immediately if the SDK is already initialized, or waits for its initialization to complete before execution.
This function checks the initialization state of the SDK. If the component is already in the
.completed
state, theexecuteHandler
is called immediately. If the component is not yet initialized, the function waits until the initialization state changes to.completed
before calling theexecuteHandler
.Important
This function MUST be set after
SendbirdChat.initialize
to work.Usage Example:
executeOrWaitForInitialization { // Code to run when already initialized or to run after initialization }
Since
4.15.0Declaration
Swift
public static func executeOrWaitForInitialization(executeHandler: @escaping () -> Void)
Parameters
executeHandler
A closure to be executed. This closure takes no parameters and returns void. It contains the code that should be executed once the SDK is initialized.
-
Performs a connection to Sendbird with the user ID.
Declaration
Swift
@objc public static func connect( userId: String, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID.
completionHandler
The handler block to execute.
user
is the object to represent the current user. -
Performs a connection to Sendbird with the user ID and the access token.
Declaration
Swift
@objc public static func connect( userId: String, authToken: String?, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID.
authToken
The auth token. If the user doesn’t have auth token, set nil.
completionHandler
The handler block to execute.
user
is the object to represent the current user. -
Performs a connection to Sendbird with the user ID and the access token.
Warning
Important: DON’T use this method. This method will be unavailable.Declaration
Swift
@objc public static func connect( userId: String, authToken: String?, apiHost: String?, wsHost: String?, completionHandler: UserHandler? = nil )
Parameters
userId
user ID
authToken
authToken
apiHost
apiHost
wsHost
wsHost
completionHandler
completionHandler
-
Authenticate with the Sendbird server. Calling this method will grant you access to Sendbird Business Messaging’s features. If you want to access Sendbird Chat’s features, call
SendbirdChat.connect
. You can deauthenticate from the Sendbird server by callingSendbirdChat.disconnect
.Note
Use thedisconnect(completionHandler:)
method to deauthenticate.Since
4.10.0Declaration
Swift
@available(*, deprecated, renamed: "authenticate") @objc public static func authenticateFeed( userId: String, authToken: String?, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID.
authToken
The auth token. If the user doesn’t have auth token, set nil.
completionHandler
The handler block to execute.
user
is the object to represent the current user. -
Authenticate with the Sendbird server. Calling this method will grant you access to Sendbird Business Messaging’s features. If you want to access Sendbird Chat’s features, call
SendbirdChat.connect
. You can deauthenticate from the Sendbird server by callingSendbirdChat.disconnect
.Note
Use thedisconnect(completionHandler:)
method to deauthenticate.Since
4.10.0Declaration
Swift
@available(*, deprecated, renamed: "authenticate") @objc public static func authenticateFeed( userId: String, authToken: String?, apiHost: String?, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID.
authToken
The auth token. If the user doesn’t have auth token, set nil.
apiHost
apiHost
completionHandler
The handler block to execute.
user
is the object to represent the current user. -
Authenticate with the Sendbird server. Calling this method will grant you access to Sendbird Business Messaging’s features. If you want to access Sendbird Chat’s features, call
SendbirdChat.connect
. You can deauthenticate from the Sendbird server by callingSendbirdChat.disconnect
.Note
Use thedisconnect(completionHandler:)
method to deauthenticate.Since
4.19.8Declaration
Swift
@objc public class func authenticate( userId: String, authToken: String?, apiHost: String? = nil, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID.
authToken
The auth token. If the user doesn’t have auth token, set nil.
apiHost
apiHost
completionHandler
The handler block to execute.
user
is the object to represent the current user. -
Disconnects from Sendbird. If this method is invoked, the current user will be invalidated.
Declaration
Swift
@objc public static func disconnect(completionHandler: VoidHandler? = nil)
Parameters
completionHandler
The handler block to execute.
-
Disconnects WebSocket only.
Since
4.4.0Declaration
Swift
@objc public static func disconnectWebSocket(completionHandler: VoidHandler? = nil)
Parameters
completionHandler
The handler block to execute.
-
Starts reconnection explictly. The
ConnectionDelegate
delegates will be invoked by the reconnection process.Declaration
Swift
@discardableResult @objc public static func reconnect() -> Bool
Return Value
true
if there is the data to be used for reconnection. -
The completion handler of background session.
Declaration
Swift
@objc public static var backgroundSessionCompletionHandler: VoidHandler? { get set }
-
Gets information set in the Application.
Since
3.0.180Declaration
Swift
@objc public static func getAppInfo() -> AppInfo?
-
Gets the WebSocket server connection state.
Declaration
Swift
@objc public static func getConnectState() -> WebSocketConnectionState
Return Value
WebSocketConnectionState
indicating socket connection state -
Creates
ApplicationUserListQuery
instance for getting a list of all users of this application.Since
3.0.120Declaration
Swift
@objc public static func createApplicationUserListQuery() -> ApplicationUserListQuery
Return Value
ApplicationUserListQuery
instance. -
Creates
ApplicationUserListQuery
instance for getting a list of all users of this application.Since
3.0.120Declaration
Swift
@objc public static func createApplicationUserListQuery( paramsBuilder: (ApplicationUserListQueryParams) -> Void ) -> ApplicationUserListQuery
Parameters
paramsBuilder
The builder closure for setting
ApplicationUserListQueryParams
.Return Value
ApplicationUserListQuery
instance. -
Creates
ApplicationUserListQuery
instance for getting a list of all users of this application.Since
3.0.120Declaration
Swift
@objc public static func createApplicationUserListQuery( params: ApplicationUserListQueryParams ) -> ApplicationUserListQuery
Parameters
params
ApplicationUserListQueryParams
instance.Return Value
ApplicationUserListQuery
instance. -
Creates
BlockedUserListQuery
instance for getting a list of blocked users by the current user.Declaration
Swift
@objc public static func createBlockedUserListQuery() -> BlockedUserListQuery
Return Value
BlockedUserListQuery
instance. -
Creates
BlockedUserListQuery
instance for getting a list of blocked users by the current user.Declaration
Swift
@objc public static func createBlockedUserListQuery( paramsBuilder: (BlockedUserListQueryParams) -> Void ) -> BlockedUserListQuery
Parameters
paramsBuilder
The builder closure for setting
BlockedUserListQueryParams
.Return Value
BlockedUserListQuery
instance. -
Creates
BlockedUserListQuery
instance for getting a list of blocked users by the current user.Declaration
Swift
@objc public static func createBlockedUserListQuery(params: BlockedUserListQueryParams) -> BlockedUserListQuery
Parameters
params
BlockedUserListQueryParams
instance.Return Value
BlockedUserListQuery
instance. -
Creates
MessageSearchQuery
instance for message searchSince
4.0.0Declaration
Swift
@objc public static func createMessageSearchQuery(builder: (MessageSearchQueryParams) -> Void) -> MessageSearchQuery
Parameters
builder
The builder closure for setting
MessageSearchQueryParams
Return Value
MessageSearchQuery
instance -
Creates
MessageSearchQuery
instance for message searchSince
4.0.0Declaration
Swift
@objc public static func createMessageSearchQuery(params: MessageSearchQueryParams) -> MessageSearchQuery
Parameters
params
The params object to change query condition.
Return Value
MessageSearchQuery
instance
-
Adds a
ConnectionDelegate
.Declaration
Swift
@available(*, deprecated, renamed: "addConnectionDelegate(_:identifier:﹚", message: "This method is deprecated in 4.0.12.") public static func add(_ delegate: ConnectionDelegate, identifier: String)
Parameters
delegate
ConnectionDelegate
delegate.identifier
The identifier for the delegate.
-
Adds a
ConnectionDelegate
.Since
4.0.12Declaration
Swift
@objc public static func addConnectionDelegate(_ delegate: ConnectionDelegate, identifier: String)
Parameters
delegate
ConnectionDelegate
delegate.identifier
The identifier for the delegate.
-
Removes the
ConnectionDelegate
by identifier.Declaration
Swift
@objc public static func removeConnectionDelegate(forIdentifier identifier: String)
Parameters
identifier
The identifier for the delegate to be removed.
-
Gets the delegate for connection by indentifer.
Declaration
Swift
@objc public static func connectionDelegate( forIdentifier identifier: String ) -> ConnectionDelegate?
Parameters
identifier
The identifier for delegate.
Return Value
ConnectionDelegate
delegate. -
Removes all connection delegates;
Declaration
Swift
@objc public static func removeAllConnectionDelegates()
-
Adds a
BaseChannelDelegate
.Declaration
Swift
@available(*, deprecated, renamed: "addChannelDelegate(_:identifier:﹚", message: "This method is deprecated in 4.0.12.") public static func add(_ delegate: BaseChannelDelegate, identifier: String)
Parameters
delegate
BaseChannelDelegate
delegate.identifier
The identifier for delegate.
-
Adds a
BaseChannelDelegate
.Since
4.0.12Declaration
Swift
@objc public static func addChannelDelegate(_ delegate: BaseChannelDelegate, identifier: String)
Parameters
delegate
BaseChannelDelegate
delegate.identifier
The identifier for delegate.
-
Removes the
BaseChannelDelegate
by identifier.Declaration
Swift
@objc public static func removeChannelDelegate(forIdentifier identifier: String)
Parameters
identifier
The identifier for the delegate to be removed.
-
Gets the delegate for channel by indentifer.
Declaration
Swift
@objc public static func channelDelegate( forIdentifier identifier: String ) -> BaseChannelDelegate?
Parameters
identifier
The identifier for delegate.
Return Value
BaseChannelDelegate
delegate. -
Removes all channel delegates
Declaration
Swift
@objc public static func removeAllChannelDelegates()
-
Gets a
UserEventDelegate
Declaration
Swift
@objc public static func userEventDelegate( forIdentifier identifier: String ) -> UserEventDelegate?
Parameters
identifier
Identifier for delegate
Return Value
UserEventDelgate
if exists -
Adds a
UserEventDelegate
Declaration
Swift
@available(*, deprecated, renamed: "addUserEventDelegate(_:identifier:﹚", message: "This method is deprecated in 4.0.12.") public static func add(_ delegate: UserEventDelegate, identifier: String)
Parameters
delegate
UserEventDelegate
instanceidentifier
String identifier for the delegate
-
Adds a
UserEventDelegate
Since
4.0.12Declaration
Swift
@objc public static func addUserEventDelegate(_ delegate: UserEventDelegate, identifier: String)
Parameters
delegate
UserEventDelegate
instanceidentifier
String identifier for the delegate
-
Removes a
UserEventDelegate
Declaration
Swift
@objc public static func removeUserEventDelegate(forIdentifier identifier: String)
Parameters
identifier
String identifier for the delegate
-
Removes all registered user event delegates
Declaration
Swift
@objc public static func removeAllUserEventDelegates()
-
Adds a
SessionDelegate
Declaration
Swift
@objc public static func setSessionDelegate(_ delegate: SessionDelegate)
Parameters
delegate
SessionDelegate
instance -
Removes the
SessionDelegate
Declaration
Swift
@objc public static func removeSessionDelegate()
-
Gets the pending push token.
Declaration
Swift
@objc public static func getPendingPushToken() -> Data?
Return Value
Returns the pending push token.
-
Registers the current device token to Sendbird.
Declaration
Swift
@objc public static func registerDevicePushToken( _ devToken: Data, unique: Bool, completionHandler: ((_ registrationStatus: PushTokenRegistrationStatus, _ error: SBError?) -> Void)? = nil )
Parameters
devToken
Device token for APNS.
unique
If
true
, register device token after removing exsiting all device tokens of the current user. Iffalse
, just add the device token.completionHandler
The handler block to execute.
status
is the status for push token registration. It is defined inPushTokenRegistrationStatus
..success
represents thedevToken
is registered..pending
represents thedevToken
is not registered because the connection is not established, so this method has to be invoked withgetPendingPushToken
method after the connection. ThedevToken
is retrived bygetPendingPushToken
..error
represents the push token registration is failed. -
Unregisters the current device token from Sendbird.
Declaration
Swift
@available(*, deprecated, message: "This method is deprecated in 4.2.4. Please use `unregisterPushToken(_ pushToken: Data, completionHandler: SBErrorHandler?﹚`") @objc public static func unregisterPushToken( _ devToken: Data, completionHandler: ((_ response: [AnyHashable: Any]?, _ error: SBError?) -> Void)? = nil )
Parameters
devToken
Device token for APNS.
completionHandler
The handler block to execute.
-
Unregisters the current device token from Sendbird.
Declaration
Swift
@objc(unregisterPushToken:completion:) public static func unregisterPushToken( _ pushToken: Data, completionHandler: SBErrorHandler? = nil )
Parameters
pushToken
Device token for APNS.
completionHandler
The handler block to execute.
-
Unregisters all device tokens for the current user from Sendbird.
Declaration
Swift
@available(*, deprecated, message: "This method is deprecated in 4.2.4. Please use `unregisterAllPushToken(completionHandler: SBErrorHandler?﹚`") @objc public static func unregisterAllPushToken( completionHandler: ((_ response: [AnyHashable: Any]?, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute.
-
Unregisters all device tokens for the current user from Sendbird.
Declaration
Swift
@objc(unregisterAllPushTokenWithCompletion:) public static func unregisterAllPushToken( completionHandler: SBErrorHandler? = nil )
Parameters
completionHandler
The handler block to execute.
-
Requests device push tokens list of current user after the token.
Since
3.0.134Declaration
Swift
@objc(getMyPushTokensWithToken:pushTokenType:completionHandler:) public static func getMyPushTokens( token: String?, pushTokenType: PushTokenType, completionHandler: @escaping GetPushTokensHandler )
Parameters
token
The token used to get next pagination of deive push tokens.
pushTokenType
The enum type to represent the type of push token.
completionHandler
The handler block to be executed after requests. This block has no return value and takes 5 arguments that are device push token list, push token type you are requesting, boolean that indicates having next pagination, token to be used next pagination and error.
-
Sets Do-not-disturb. This method make snooze(or stop snooze) repeatedly. If you want to snooze specific period, use
setSnoozePeriodEnable(:startTimestamp:endTimestamp:completionHandler:)
.Declaration
Swift
@objc public static func setDoNotDisturb( enable: Bool, startHour: Int32, startMin: Int32, endHour: Int32, endMin: Int32, timezone: String, completionHandler: SBErrorHandler? = nil )
Parameters
enable
Enables or not.
startHour
Start hour.
startMin
Start minute.
endHour
End hour.
endMin
End minute.
timezone
Sets timezone.
completionHandler
The handler block to execute.
-
Gets Do-not-disturb.
Declaration
Swift
@objc public static func getDoNotDisturb( completionHandler: ((_ enabled: Bool, _ startHour: Int, _ startMin: Int, _ endHour: Int, _ endMin: Int, _ timezone: String, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute.
-
Makes a current user snooze/receive remote push notification in specific duration.
If you use
SendbirdChat setDoNotDisturb(enable:startHour:startMin:endHour:endMin:timezone:completionHandler:)
method as well, both methods are applied together. Keep in mind snoozing(or stop snoozing) is applied from this method only once, not repeatedly. If you want to snooze(do not disturb) repeatedly, useSendbirdChat setDoNotDisturb(enable:startHour:startMin:endHour:endMin:timezone:completionHandler:)
.Since
3.0.128Declaration
Swift
@objc public static func setSnoozePeriod( enabled: Bool, startTimestamp: Int64, endTimestamp: Int64, completionHandler: SBErrorHandler? = nil )
Parameters
enabled
Enabled means snooze remote push notification in duration. If set to disabled, current user can ///receive remote push notification.
startTimestamp
Unix timestamp to start snooze.
endTimestamp
Unix timestamp to end snooze.
completionHandler
The handler block to execute when setting notification snoozed is complete.
-
Requests whether the current user snooze remote push notification.
Since
3.0.128Declaration
Swift
@objc public static func getSnoozePeriod( _ completionHandler: @escaping SnoozePeriodHandler )
Parameters
completionHandler
The handler block to execute when setting notification snoozed is complete.
-
Changes a setting that decides which push notification for the current user to receive in all of the group channel.
Since
3.0.128Declaration
Swift
@objc public static func setPushTriggerOption( _ pushTriggerOption: PushTriggerOption, completionHandler: SBErrorHandler? = nil )
Parameters
pushTriggerOption
The options to choose which push notification for the current user to receive.
completionHandler
The handler block to execute when setting a push trigger option of the current ///user is completed.
-
Requests a setting that decides which push notification for the current user to receive in all of the group channel.
Since
3.0.128Declaration
Swift
@objc public static func getPushTriggerOption( completionHandler: @escaping PushTriggerOptionHandler )
Parameters
completionHandler
The handler block to execute when getting a push trigger of the current user is ///completed.
-
Sets push sound
Declaration
Swift
@objc public static func setPushSound( _ sound: String, completionHandler: SBErrorHandler? = nil )
Parameters
sound
Push sound
completionHandler
The handler block to be executed after set push sound.
-
Gets push shound
Declaration
Swift
@objc public static func getPushSound( completionHandler: ((_ pushSound: String?, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute.
-
Sets a push template of the current user.
Declaration
Swift
@objc public static func setPushTemplate( name: String, completionHandler: SBErrorHandler? = nil )
Parameters
name
The name of push template. Uses
SendbirdChat.PushTemplate
constantscompletionHandler
The handler block to execute.
-
Gets a push template of the current user.
Declaration
Swift
@objc public static func getPushTemplate( completionHandler: ((_ pushTemplate: String?, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute. The
name
is the current user’s push template. -
Sets group channel invitation preference for auto acceptance.
Declaration
Swift
@objc public static func setChannelInvitationPreference( autoAccept: Bool, completionHandler: SBErrorHandler? = nil )
Parameters
autoAccept
If
true
, the current user will accept the group channel invitation automatically.completionHandler
The handler block to execute.
-
Gets group channel inviation preference for auto acceptance.
Declaration
Swift
@objc public static func getChannelInvitationPreferenceAutoAccept( completionHandler: ((_ autoAccept: Bool, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute.
-
Creates
FriendListQuery
instance for friend listSince
4.0.0Declaration
Swift
@objc public static func createFriendListQuery() -> FriendListQuery
Return Value
FriendListQuery
instance -
Creates
FriendListQuery
instance for friend listSince
4.0.0Declaration
Swift
@objc public static func createFriendListQuery(paramsBuilder: (FriendListQueryParams) -> Void) -> FriendListQuery
Parameters
paramsBuilder
The builder closure for setting
FriendListQueryParams
.Return Value
FriendListQuery
instance -
Creates
FriendListQuery
instance for friend listSince
4.0.0Declaration
Swift
@objc public static func createFriendListQuery(params: FriendListQueryParams) -> FriendListQuery
Parameters
params
The params object to change query condition.
Return Value
FriendListQuery
instance -
Sets current user to be discoverable by others
Since
3.0.205Declaration
Swift
@objc public static func setAllowFriendDiscovery( _ allow: Bool, completionHandler: SBErrorHandler? = nil )
Parameters
allow
if
true
, current user will be set to discoverable by others -
Gets a flag whether current user is discoverable or not by others
Since
3.0.205Declaration
Swift
@objc public static func getAllowFriendDiscovery( completionHandler: ((_ allowFriendDiscovery: Bool, _ error: SBError?) -> Void)? = nil )
-
Deletes a given user ID from friend list
Declaration
Swift
@objc public static func deleteFriend( userId: String, completionHandler: SBErrorHandler? = nil )
Parameters
userId
user ID
completionHandler
completion handler
-
Deletes a given list of user from friend list
Declaration
Swift
@objc public static func deleteFriends( userIds: [String], completionHandler: SBErrorHandler? = nil )
Parameters
userIds
user ID list
completionHandler
completion handler
-
Deletes a friend with given discovery key
Declaration
Swift
@objc public static func deleteFriend( discoveryKey: String, completionHandler: SBErrorHandler? = nil )
Parameters
discoveryKey
discovery key that associates with friend
completionHandler
completion handler
-
Deletes list of friends with given discovery keys
Declaration
Swift
@objc public static func deleteFriends( discoveryKeys: [String], completionHandler: SBErrorHandler? = nil )
Parameters
discoveryKeys
list of discovery key that associates with friends
completionHandler
completion handler
-
Uploads discovery key and corresponding name
Declaration
Swift
@objc public static func uploadFriendDiscoveries( _ discoveryKeyAndNames: [String: String], completionHandler: SBErrorHandler? = nil )
Parameters
discoveryKeyAndNames
a dictionary contains discovery key as key and name as value
completionHandler
completion handler
-
Fetches friends’ change log
Declaration
Parameters
token
a string to pagniate next page
completionHandler
completion handler
-
Gets the number of group channel with the filter.
Since
3.0.116Declaration
Swift
@objc(getGroupChannelCountWithMyMemberStateFilter:completionHandler:) public static func getGroupChannelCount( myMemberStateFilter: MyMemberStateFilter, completionHandler: @escaping CountHandler )
Parameters
myMemberStateFilter
The member state of the current user in the channels that are counted.
completionHandler
The handler block to execute.
-
Gets the total unread channel count of all group channels.
Since
3.0.116Declaration
Swift
@objc public static func getTotalUnreadChannelCount( completionHandler: @escaping CountHandler )
Parameters
completionHandler
The handler block to execute. The
unreadCount
is the total count of unread channels in all of group channel which the current is a member. -
Gets the total unread channel count of all group channels with filters of params.
Since
3.1.7Declaration
Swift
@objc public static func getTotalUnreadChannelCount( params: GroupChannelTotalUnreadChannelCountParams, completionHandler: @escaping CountHandler )
Parameters
params
The instance of parameters to filter.
completionHandler
The handler block to execute. The
unreadCount
is the total count of unread group channels of which the current user is a member, filtered byparams
. -
Gets the number of unread messages in group channels.
Since
3.0.116Declaration
Swift
@objc public static func getTotalUnreadMessageCount( completionHandler: @escaping CountHandler )
Parameters
completionHandler
The handler block to execute. The
unreadCount
is the total count of unread messages in all of group channel which the current is a member. -
Gets the number of unread notifications in feed channels.
Since
4.19.8Declaration
Swift
@objc public class func getTotalUnreadNotificationsCount( completionHandler: @escaping CountHandler )
Parameters
completionHandler
The handler block to execute. The
unreadCount
is the total count of unread notifications in all of feed channel which the current is a member of.. -
Gets the total unread message count of the channels with filters of params.
Since
3.0.116Declaration
Swift
@available(*, deprecated, renamed: "getTotalUnreadMessageCountWithFeed(params:completionHandler:﹚", message: "This method is deprecated in 4.6.0.") @objc public static func getTotalUnreadMessageCount( params: GroupChannelTotalUnreadMessageCountParams, completionHandler: @escaping CountHandler )
Parameters
params
The instance of parameters to filter.
completionHandler
The handler block to be executed after getting total unread message count. This block has no return value and takes two argument, the one is the number of unread message and the other is error.
-
Gets the total unread message count of the channels with filters of params.
Since
4.6.0Declaration
Swift
@objc public static func getTotalUnreadMessageCountWithFeed( params: GroupChannelTotalUnreadMessageCountParams, completionHandler: @escaping UnreadMessageCountHandler )
Parameters
params
The instance of parameters to filter.
completionHandler
The handler block to be executed after getting total unread message count. This block has no return value and takes two argument, the one is the number of unread message and the other is error.
-
Gets unread messages and mentions counts of message and invitation counts in super and non_super channels.
Since
3.0.116
Declaration
Swift
@available(*, deprecated, renamed: "getUnreadItemCount(params:completionHandler:﹚", message: "This method is deprecated in 4.21.0. Set `key` in `GroupChannelUnreadItemCountParams` and use `getUnreadItemCount(params:completionHandler:﹚` instead.") @objc public static func getUnreadItemCount( key: UnreadItemKey, completionHandler: @escaping (_ count: UnreadItemCount?, _ error: SBError?) -> Void )
Parameters
key
UnreadItemKey
optionSets to contain count flagscompletionHandler
The handler block to be executed after getting unread item count. This block has no return value and takes two argument. the one is type of UnreadItemCount that contains unsinged interger for count you requested. the other is an error made when there is something wrong to response.
-
Gets unread messages and mentions counts of message and invitation counts in super and non_super channels.
Since
4.21.0
Declaration
Swift
@objc public static func getUnreadItemCount( params: GroupChannelUnreadItemCountParams, completionHandler: @escaping (_ count: UnreadItemCount?, _ error: SBError?) -> Void )
Parameters
params
completionHandler
The handler block to be executed after getting unread item count. This block has no return value and takes two argument. the one is type of
UnreadItemCount
that contains unsinged interger for count you requested. The other is an error made when there is something wrong to response. -
Gets total unread message count for current user
Declaration
Swift
@objc public static func getSubscribedTotalUnreadMessageCount() -> Int
-
Gets total unread message count that is subscribed with custom types for current user
Declaration
Swift
@objc public static func getSubscribedCustomTypeTotalUnreadMessageCount() -> Int
-
Gets unread message count on channels with given custom type for current user
Declaration
Swift
@objc public static func getSubscribedCustomTypeUnreadMessageCount( customType: String ) -> Int
-
Marks as read all group channels of the current user.
Declaration
Swift
@objc public static func markAsReadAll(completionHandler: SBErrorHandler? = nil)
Parameters
completionHandler
The handler block to execute.
-
Marks as read some group channels of the current user.
Declaration
Swift
@objc public static func markAsRead( channelURLs: [String], completionHandler: SBErrorHandler? = nil )
Parameters
channelURLs
The array list with channel urls to be marked as read.
completionHandler
The handler block to execute.
-
Marks as delivered with the payload of the remote notification.
Since
3.0.183Declaration
Swift
@objc public static func markAsDelivered( remoteNotificationPayload: [AnyHashable: Any], completionHandler: SBErrorHandler? = nil )
Parameters
remoteNotificationPayload
The remote notification payload
completionHandler
The handler block to execute
-
Marks push notification as delivered for push delivery tracking purpose only. It is only work for
Notification Service Extension
. This does not mark the message as delivered.Since
4.10.0Declaration
Swift
@objc public static func markPushNotificationAsDelivered( remoteNotificationPayload: [AnyHashable: Any], completionHandler: SBErrorHandler? = nil )
Parameters
remoteNotificationPayload
The remote notification payload
completionHandler
The handler block to execute
-
Marks push notification as delivered for push delivery tracking purpose only. It is only work for
Notification Service Extension
. This does not mark the message as delivered.Since
4.19.8Declaration
Swift
@objc public class func markPushNotificationAsDelivered( apiHost: String? = nil, remoteNotificationPayload: [AnyHashable: Any], completionHandler: SBErrorHandler? = nil )
Parameters
apiHost
The API host. If nil, the default host is used.
remoteNotificationPayload
The remote notification payload
completionHandler
The handler block to execute
-
Marks push notification as clicked for push tracking purpose only. This does not mark the message as delivered.
Since
4.18.0Declaration
Swift
@objc public static func markPushNotificationAsClicked( remoteNotificationPayload: [AnyHashable: Any], completionHandler: SBErrorHandler? = nil )
Parameters
remoteNotificationPayload
The remote notification payload
completionHandler
The handler block to execute
-
Marks push notification as clicked for push tracking purpose only. This does not mark the message as delivered.
Since
4.19.8Declaration
Swift
@objc public class func markPushNotificationAsClicked( apiHost: String? = nil, remoteNotificationPayload: [AnyHashable: Any], completionHandler: SBErrorHandler? = nil )
Parameters
apiHost
The API host. If nil, the default host is used.
remoteNotificationPayload
The remote notification payload
completionHandler
The handler block to execute
-
Requests updated channels and deleted channel URLs since a certain time. A certain time is decided by a token.
Since
3.0.182Declaration
Swift
@objc(getMyGroupChannelChangeLogsWithToken:params:completionHandler:) public static func getMyGroupChannelChangeLogs( token: String?, params: GroupChannelChangeLogsParams = GroupChannelChangeLogsParams(), completionHandler: @escaping ChannelChangeLogsHandler )
Parameters
token
The token used to get next pagination of changelogs.
params
the parameter object that filters a result. See
GroupChannelChangeLogsParams
for more detailcompletionHandler
The handler type of
ChannelChangeLogsHandler
block to execute. TheupdatedChannels
is the channels that were updated. ThedeletedChannelURLs
is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, thehasMore
istrue
. Thetoken
can be used to get more changedlogs. -
Requests updated channels and deleted channel URLs since the timestamp.
Since
3.0.182Declaration
Swift
@objc(getMyGroupChannelChangeLogsWithTimestamp:params:completionHandler:) public static func getMyGroupChannelChangeLogs( timestamp: Int64, params: GroupChannelChangeLogsParams = GroupChannelChangeLogsParams(), completionHandler: @escaping ChannelChangeLogsHandler )
Parameters
timestamp
The number of milli-seconds(msec). Requests changelogs from that time. This value must not be negative.
params
the parameter object that filters a result. See
GroupChannelChangeLogsParams
for more detailcompletionHandler
The handler type of
ChannelChangeLogsHandler
block to execute. TheupdatedChannels
is the channels that were updated. ThedeletedChannelURLs
is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, thehasMore
istrue
. Thetoken
can be used to get more changedlogs. -
Fetches updated user list since a certain time. A certain time is decided by a token.
Since
4.11.1Declaration
Swift
@objc(getMembersChangeLogsWithToken:completionHandler:) public static func getMembersChangeLogs( token: String, completionHandler: @escaping MembersChangeLogsHandler )
Parameters
token
The token used to get next pagination of changelogs.
completionHandler
The handler type of
MembersChangeLogsHandler
block to execute. -
Fetches updated user list since the timestamp.
Since
4.11.1Declaration
Swift
@objc(getMembersChangeLogsWithTimestamp:completionHandler:) public static func getMembersChangeLogs( timestamp: Int64, completionHandler: @escaping MembersChangeLogsHandler )
Parameters
timestamp
The number of milli-seconds(msec). Requests changelogs from that time. This value must not be negative.
completionHandler
The handler type of
MembersChangeLogsHandler
block to execute.
-
Retrieves the log level.
Declaration
Swift
@objc public static func getLogLevel() -> LogLevel
Return Value
Log level.
-
Gets mime type of file.
Declaration
Swift
@objc public static func getMimeType(_ file: Data?) -> String?
Parameters
file
File to get mime type.
Return Value
Returns mime type of the file.
-
Turns on or off the reconnection by network awareness.
Declaration
Swift
@objc public static func setNetworkAwarenessReconnection(_ isOn: Bool)
Parameters
isOn
If
true
, the reconnection by network Awareness is turned. -
Sendbird user agent information getter.
Declaration
Swift
@objc public static func getSBUserAgent() -> String
-
Initialize
sharedContainerIdentifier
of NSURLSessionConfiguration to use background session.Important
If you use
App Extension
and use upload file message in extension, you MUST set thie field.Declaration
Swift
@objc public static func setSharedContainerIdentifier(_ identifier: String)
Parameters
identifier
The identifier to set background session configuraion.
-
Sets dispatch queue for every completion handler and delegate. Default queue is the main queue.
Important
This function must be used after the initialize function of SendbirdChat.
Declaration
Swift
@objc public static func setCompletionHandlerDelegateQueue(_ queue: DispatchQueue)
Parameters
queue
Dispatch queue for every completion handler and delegate.
-
Runs block in the dispatch queue that was set by
setCompletionHandlerDelegateQueue(_:)
.Declaration
Swift
@objc public static func performCompletionHandlerDelegateQueue(_ block: (() -> Void)? = nil)
Parameters
block
Block to run.
-
Sets the app group.
Since
3.0.183Declaration
Swift
@objc public static func setAppGroup(_ appGroup: String)
Parameters
appGroup
The app group.
-
Gets the key to authenticate the file URL.
This has to be put into the HTTP header when the client needs to access it.
Since
3.0.194Declaration
Swift
@objc public static func ekey() -> String?
Return Value
The key to authenticate the file URL
-
Requests a emoji container which contains hash and list of emoji category.
Since
3.0.180Declaration
Swift
@objc public static func getAllEmojis( _ completionHandler: ((_ emojiContainer: EmojiContainer?, _ error: SBError?) -> Void)? = nil )
Parameters
completionHandler
The handler block to execute after request is completed
-
Requests updated channels and deleted channel URLs since the timestamp.
Since
3.0.180Declaration
Parameters
emojiKey
The emoji key
completionHandler
The handler block to execute after request is completed
-
Requests updated channels and deleted channel URLs since the timestamp.
Since
3.0.180Declaration
Swift
@objc public static func getEmojiCategory( _ categoryId: Int64, completionHandler: ((_ emojiCategory: EmojiCategory?, _ error: SBError?) -> Void)? = nil )
Parameters
categoryId
The category ID
completionHandler
The handler block to execute after request is completed
-
Gets the current user object.
The object is valid when the connection succeeded.
Declaration
Swift
@objc public static func getCurrentUser() -> User?
Return Value
The current user object.
-
Gets the current user’s latest connection millisecond time(UTC).
If the connection state is not public, Returns 0.
Since
3.0.117Declaration
Swift
@objc public static func getLastConnectedAt() -> Int64
Return Value
latest connected millisecond time stamp.
-
Updates the current user’s information
Since
4.0.0Declaration
Swift
@objc public static func updateCurrentUserInfo( params: UserUpdateParams, progressHandler: ProgressHandler? = nil, completionHandler: SBErrorHandler? = nil )
Parameters
params
UserUpdateParams
instanceprogressHandler
The handler block to monitor progression.
bytesSent
is the number of bytes sent ///since the last time this method was called.totalBytesSent
is the total number of bytes sent so far. ///totalBytesExpectedToSend
is the expected length of the body data. -
Updates the current user’s preferred languages
Declaration
Swift
@objc public static func updateCurrentUserInfo( preferredLanguages: [String], completionHandler: SBErrorHandler? = nil )
Parameters
preferredLanguages
New array of preferred languages
completionHandler
The handler block to execute.
-
Blocks the specified user.
Declaration
Swift
@objc public static func blockUserId( _ userId: String, completionHandler: UserHandler? = nil )
Parameters
userId
The user ID to be blocked.
completionHandler
The handler block to execute.
blockedUser
is the blocked user by the current user. -
Blocks the specified user.
Declaration
Swift
@objc public static func blockUser( _ user: User, completionHandler: UserHandler? = nil )
Parameters
user
The user to be blocked.
completionHandler
The handler block to execute.
blockedUser
is the blocked user by the current user. -
Unblocks the specified user.
Declaration
Swift
@objc public static func unblockUserId( _ userId: String, completionHandler: SBErrorHandler? = nil )
Parameters
userId
The user ID which was blocked.
completionHandler
The handler block to execute.
-
Unblocks the specified user.
Declaration
Swift
@objc public static func unblockUser( _ user: User, completionHandler: SBErrorHandler? = nil )
Parameters
user
The user who was blocked.
completionHandler
The handler block to execute.
-
Creates a group channel collection
Declaration
Swift
@objc public static func createGroupChannelCollection( query: GroupChannelListQuery ) -> GroupChannelCollection?
Parameters
query
GroupChannelListQuery
instanceReturn Value
GroupChannelCollection
instance -
Creates a message collection
Declaration
Swift
@objc public static func createMessageCollection( channel: GroupChannel, startingPoint: Int64, params: MessageListParams ) -> MessageCollection
Parameters
channel
GroupChannel
instancestartingPoint
Epoch timestamp that will be used as pivot point to fetch messages
params
MessageListParams
instance -
Since
4.6.0Declaration
Swift
@objc public static func createNotificationCollection( channel: FeedChannel, startingPoint: Int64, params: MessageListParams, delegate: NotificationCollectionDelegate? ) -> NotificationCollection?
-
Clears local cached data
Declaration
Swift
@objc public static func clearCachedData(completionHandler: SBErrorHandler?)
Parameters
completionHandler
completion
-
Clears local cached message
Declaration
Swift
@objc public static func clearCachedMessages(channelURL: String, completionHandler: SBErrorHandler?)
Parameters
channelURL
channel URL
completionHandler
completion
-
Returns local cached data size in byte
Declaration
Swift
@objc public static func getCachedDataSize() -> Int
Return Value
cached data size
-
Checks if local caching is enabled.
Since
3.1.0Declaration
Swift
@objc public static var isLocalCachingEnabled: Bool { get }
-
Gets the number of scheduled messages.
Since
4.0.0Declaration
Swift
@objc public static func getTotalScheduledMessageCount( params: TotalScheduledMessageCountParams, completionHandler: @escaping CountHandler )
Parameters
params
The object that contains a set of options to get scheduled messages.
completionHandler
The handler block to be executed after the total scheduled message count in the channel is fetched or an error occurs.
-
Creates
ScheduledMessageListQuery
for getting the list of scheduled messages.Since
4.0.0Declaration
Swift
@objc public static func createScheduledMessageListQuery( channelURL: String? ) -> ScheduledMessageListQuery
Parameters
channelURL
The channel URL. If
channelURL
is nil, you will get scheduled messages for all channels.Return Value
The scheduled message list query object.
-
Creates
ScheduledMessageListQuery
for getting the list of scheduled messages.Since
4.0.0Declaration
Swift
@objc public static func createScheduledMessageListQuery( channelURL: String?, paramsBuilder: (ScheduledMessageListQueryParams) -> Void ) -> ScheduledMessageListQuery
Parameters
channelURL
The channel URL. If
channelURL
is nil, you will get scheduled messages for all channels.paramsBuilder
The builder closure for setting
ScheduledMessageListQueryParams
.Return Value
The scheduled message list query object.
-
Creates
ScheduledMessageListQuery
for getting the list of scheduled messages.Since
4.0.0Declaration
Swift
@objc public static func createScheduledMessageListQuery( channelURL: String?, params: ScheduledMessageListQueryParams ) -> ScheduledMessageListQuery
Parameters
channelURL
The channel URL. If
channelURL
is nil, you will get scheduled messages for all channels.params
The params object to change query condition.
Return Value
The scheduled message list query object.
-
Creates
PollListQuery
Since
4.1.0Declaration
Swift
@objc public static func createPollListQuery(params: PollListQueryParams) -> PollListQuery
Parameters
params
The params object to change query condition.
Return Value
PollListQuery
instance -
Creates
PollListQuery
Since
4.1.0Declaration
Swift
@objc public static func createPollListQuery(paramsBuilder: (PollListQueryParams) -> Void) -> PollListQuery
Parameters
paramsBuilder
The builder closure for setting
PollListQueryParams
.Return Value
PollListQuery
instance. -
Creates
PollVoterListQuery
Since
4.1.0Declaration
Swift
@objc public static func createPollVoterListQuery(params: PollVoterListQueryParams) -> PollVoterListQuery
Parameters
params
The params object to change query condition.
Return Value
PollVoterListQuery
instance. -
Creates
PollVoterListQuery
with paramsBuilder.Declaration
Swift
@objc public static func createPollVoterListQuery(paramsBuilder: (PollVoterListQueryParams) -> Void) -> PollVoterListQuery
Parameters
paramsBuilder
The builder closure for setting
GroupChannelListQueryParams
.Return Value
GroupChannelListQuery instance for the current user.
-
Requests updated feed channels and deleted feed channel URLs since a certain time. A certain time is decided by a timestamp.
Since
4.6.0Declaration
Swift
@objc public static func getMyFeedChannelChangeLogs( timestamp: Int64, params: FeedChannelChangeLogsParams = FeedChannelChangeLogsParams(), completionHandler: @escaping FeedChannelChangeLogsHandler )
Parameters
timestamp
The number of milli-seconds(msec). Requests changelogs from that time. This value must not be negative.
params
the parameter object that filters a result. See
FeedChannelChangeLogsParams
for more detailcompletionHandler
The handler type of
FeedChannelChangeLogsHandler
block to execute. TheupdatedChannels
is the channels that were updated. ThedeletedChannelURLs
is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, thehasMore
istrue
. Thetoken
can be used to get more changedlogs. -
Requests updated feed channels and deleted feed channel URLs since a certain time. A certain time is decided by a token.
Since
4.6.0Declaration
Swift
@objc public static func getMyFeedChannelChangeLogsByToken( token: String?, params: FeedChannelChangeLogsParams = FeedChannelChangeLogsParams(), completionHandler: @escaping FeedChannelChangeLogsHandler )
Parameters
token
The token used to get next pagination of changelogs.
params
the parameter object that filters a result. See
FeedChannelChangeLogsParams
for more detailcompletionHandler
The handler type of
FeedChannelChangeLogsHandler
block to execute. TheupdatedChannels
is the channels that were updated. ThedeletedChannelURLs
is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, thehasMore
istrue
. Thetoken
can be used to get more changedlogs. -
Since
4.6.0Declaration
Swift
@objc public static func getUnreadMessageCount() -> UnreadMessageCount
-
Since
4.6.0Declaration
Swift
@objc public static func getGlobalNotificationChannelSetting( completionHandler: @escaping GlobalNotificationChannelSettingHandler )
-
Since
4.6.0Declaration
Swift
@objc public static func getNotificationTemplateList( token: String?, params: NotificationTemplateListParams = NotificationTemplateListParams(), completionHandler: @escaping NotificationTemplateListHandler )
-
Since
4.6.0Declaration
Swift
@objc public static func getNotificationTemplate( key: String, completionHandler: @escaping NotificationTemplateHandler )
-
Since
4.17.0Declaration
Swift
@objc public static func getMessageTemplateList( token: String?, params: MessageTemplateListParams = MessageTemplateListParams(), completionHandler: @escaping MessageTemplateListHandler )
-
Since
4.17.0Declaration
Swift
@objc public static func getMessageTemplate( key: String, completionHandler: @escaping MessageTemplateHandler )
-
Since
4.8.4Declaration
Swift
public static func __getUIKitConfiguration( completionhandler: @escaping UIKitConfigurationHandler )
-
Refresh the contents of all notification collections that are currently valid. Notification collection must be valid with
isLive
flag beingtrue
.Since
4.10.0Declaration
Swift
public static func refreshNotificationCollections()
-
Send a user message by specifying a channel type, channel URL, and the parameters to send the user message with the given parameters.
Note
This method just sends the message through API. In most scenarios, you should call
GroupChannel.getChannel
orOpenChannel.getChannel
and use the retrieved channel objects to send and receive messages. This method is for sending message without getting the channel object when the application execution time is limited, such as in app extensions.Declaration
Swift
@objc public static func sendUserMessage(channelType: ChannelType, channelURL: String, params: UserMessageCreateParams, completionHandler: UserMessageHandler?)
Parameters
channelType
The channel type of the channel to send the message in.
channelURL
The channel URL of the channel to send the message in.
params
The instance of
UserMessageCreateParams
that can has parameters related with string message.completionHandler
The handler block to be executed after the message was sent. This block has no return value and takes two argument, one is a file message was sent and other is an error made when there is something wrong to message.
-
Undocumented
See moreDeclaration
Swift
@objc(SBDPushTemplate) class PushTemplate : NSObject
-
Used to set the version information of the Sendbird SDK extension.
Declaration
Swift
@objc public static func __addExtension(_ key: String, version: String)
Parameters
key
Extension sdk’s hidden key
version
Extension sdk’s version string
-
Used to set the version information of the Sendbird SDK extension.
Declaration
Swift
@available(*, deprecated, renamed: "__addExtension(_:version:﹚", message: "This method is deprecated in 4.8.3") @objc public static func addExtension(_ key: String, version: String)
Parameters
key
Extension sdk’s hidden key
version
Extension sdk’s version string
-
Used to set the version information of the Sendbird SDK extensions in user agent.
Since
4.8.5Declaration
Swift
public static func __addSendbirdExtensions(extensions: [__SendbirdSDKInfo], customData: [String : String]?) -> Bool
Parameters
extensions
A non-empty array of extension SDKs’ versions.
customData
Custom data in String to add in user agent.
Return Value
false if extensions don’t satisfy Semantic Versioning or custom data includes “&” or “=”.