SendbirdChat

public 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.

Delegates

Push

  • Gets the pending push token.

    Declaration

    Swift

    @objc
    public class func getPendingPushToken() -> Data?

    Return Value

    Returns the pending push token.

  • Registers the current device token to Sendbird.

    Declaration

    Swift

    @objc
    public class 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. If false, just add the device token.

    completionHandler

    The handler block to execute. status is the status for push token registration. It is defined in PushTokenRegistrationStatus. .success represents the devToken is registered. .pending represents the devToken is not registered because the connection is not established, so this method has to be invoked with getPendingPushToken method after the connection. The devToken is retrived by getPendingPushToken. .error represents the push token registration is failed.

  • Unregisters the current device token from Sendbird.

    Declaration

    Swift

    @objc
    public class 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 all device tokens for the current user from Sendbird.

    Declaration

    Swift

    @objc
    public class func unregisterAllPushToken(
        completionHandler: ((_ response: [AnyHashable: Any]?, _ error: SBError?) -> Void)? = nil
    )

    Parameters

    completionHandler

    The handler block to execute.

  • Requests device push tokens list of current user after the token.

    Since

    3.0.134

    Declaration

    Swift

    @objc(getMyPushTokensWithToken:pushTokenType:completionHandler:)
    public class 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.

Preference

  • 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 class 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 class 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, use SendbirdChat setDoNotDisturb(enable:startHour:startMin:endHour:endMin:timezone:completionHandler:).

    Since

    3.0.128

    Declaration

    Swift

    @objc
    public class 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.128

    Declaration

    Swift

    @objc
    public class 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.128

    Declaration

    Swift

    @objc
    public class 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.128

    Declaration

    Swift

    @objc
    public class 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 class 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 class 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 class func setPushTemplate(
        name: String,
        completionHandler: SBErrorHandler? = nil
    )

    Parameters

    name

    The name of push template. Uses SendbirdChat.PushTemplate constants

    completionHandler

    The handler block to execute.

  • Gets a push template of the current user.

    Declaration

    Swift

    @objc
    public class 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 class 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 class func getChannelInvitationPreferenceAutoAccept(
        completionHandler: ((_ autoAccept: Bool, _ error: SBError?) -> Void)? = nil
    )

    Parameters

    completionHandler

    The handler block to execute.

Friend

Info

  • Gets the number of group channel with the filter.

    Since

    3.0.116

    Declaration

    Swift

    @objc(getGroupChannelCountWithMyMemberStateFilter:completionHandler:)
    public class 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.116

    Declaration

    Swift

    @objc
    public class 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.7

    Declaration

    Swift

    @objc
    public class func getTotalUnreadChannelCount(
        params: GroupChannelTotalUnreadChannelCountParams,
        completionHandler: @escaping CountHandler
    )
  • Gets the number of unread messages in group channels.

    Since

    3.0.116

    Declaration

    Swift

    @objc
    public class 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 total unread message count of the channels with filters of params.

    Since

    3.0.116

    Declaration

    Swift

    @objc
    public class 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.

  • Get unread counts of message and invitation counts in super and non_super channels.

    Since

    3.0.116

    Declaration

    Swift

    @objc
    public class func getUnreadItemCount(
        key: UnreadItemKey,
        completionHandler: @escaping (_ count: UnreadItemCount?, _ error: SBError?) -> Void
    )

    Parameters

    key

    UnreadItemKey optionSets to contain count flags

    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 class func getSubscribedTotalUnreadMessageCount() -> Int
  • Gets total unread message count that is subscribed with custom types for current user

    Declaration

    Swift

    @objc
    public class func getSubscribedCustomTypeTotalUnreadMessageCount() -> Int
  • Gets unread message count on channels with given custom type for current user

    Declaration

    Swift

    @objc
    public class func getSubscribedCustomTypeUnreadMessageCount(
        customType: String
    ) -> Int

Channel

  • Marks as read all group channels of the current user.

    Declaration

    Swift

    @objc
    public class 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 class 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.183

    Declaration

    Swift

    @objc
    public class func markAsDelivered(
        remoteNotificationPayload: [AnyHashable: Any],
        completionHandler: SBErrorHandler? = nil
    )

    Parameters

    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.182

    Declaration

    Swift

    @objc(getMyGroupChannelChangeLogsWithToken:params:completionHandler:)
    public class func getMyGroupChannelChangeLogs(
        token: String?,
        params: 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 detail

    completionHandler

    The handler type of ChannelChangeLogsHandler block to execute. The updatedChannels is the channels that were updated. The deletedChannelURLs is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, the hasMore is true. The token can be used to get more changedlogs.

  • Requests updated channels and deleted channel URLs since the timestamp.

    Since

    3.0.182

    Declaration

    Swift

    @objc(getMyGroupChannelChangeLogsWithTimestamp:params:completionHandler:)
    public class func getMyGroupChannelChangeLogs(
        timestamp: Int64,
        params: 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 detail

    completionHandler

    The handler type of ChannelChangeLogsHandler block to execute. The updatedChannels is the channels that were updated. The deletedChannelURLs is the list of the deleted channel URLs. If there are more changelogs that are not returned yet, the hasMore is true. The token can be used to get more changedlogs.

Configuration

  • Retrieves the log level.

    Declaration

    Swift

    @objc
    public class func getLogLevel() -> LogLevel

    Return Value

    Log level.

  • Sets the log level. The log level is defined by LogLevel.

    Declaration

    Swift

    @objc
    public class func setLogLevel(_ logLevel: LogLevel)

    Parameters

    logLevel

    Log level.

  • Gets mime type of file.

    Declaration

    Swift

    @objc
    public class 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 class func setNetworkAwarenessReconnection(_ isOn: Bool)

    Parameters

    isOn

    If true, the reconnection by network Awareness is turned.

  • Sendbird user agent information getter.

    Declaration

    Swift

    @objc
    public class func getSBUserAgent() -> String
  • Used to set the version information of the Sendbird SDK extension.

    Declaration

    Swift

    @objc
    public class func addExtension(_ key: String, version: String)

    Parameters

    key

    Extension sdk’s hidden key

    version

    Extension sdk’s version 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 class 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.

    Declaration

    Swift

    @objc
    public class 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 class func performCompletionHandlerDelegateQueue(_ block: (() -> Void)? = nil)

    Parameters

    block

    Block to run.

  • Sets the app group.

    Since

    3.0.183

    Declaration

    Swift

    @objc
    public class 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.194

    Declaration

    Swift

    @objc
    public class func ekey() -> String?

    Return Value

    The key to authenticate the file URL

Emoji

  • Requests a emoji container which contains hash and list of emoji category.

    Since

    3.0.180

    Declaration

    Swift

    @objc
    public class 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.180

    Declaration

    Swift

    @objc
    public class func getEmoji(
        _ emojiKey: String,
        completionHandler: ((_ emoji: Emoji?, _ error: SBError?) -> Void)? = nil
    )

    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.180

    Declaration

    Swift

    @objc
    public class 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

User