Chat UIKit SwiftUI v3
Chat UIKit SwiftUI
Chat UIKit
SwiftUI
Version 3

Global classes

Copy link

The following shows classes with set values and data that are applied globally to the entire Sendbird Chat SwiftUI.


SBUUser

Copy link

The SBUUser class encapsulates user information for Sendbird Chat's SwiftUI UIKit. This class can be created using the User, Member, or Sender classes.

List of properties

Copy link
Properties
RequiredTypeDescription

userId

String

Specifies the unique ID of the user.

OptionalTypeDescription

nickname

String?

Specifies the user's nickname. (Default: nil)

profileURL

String?

Specifies the URL of the user's profile image. (Default: nil)

isOperator

Bool

Specifies the user is an operator. (Default: false)

isMuted

Bool

Specifies the user is muted in the channel. (Default: false)

Note: For a comprehensive list of properties and details, refer to the SBUUser official documentation.

Usage Example

Copy link

Below is an example of initializing and using the SBUUser class in Swift:

// Creating an SBUUser instance
let user = SBUUser(
    userId: {USER_ID},
    nickname: {NICKNAME},
    profileURL: {PROFILE_URL}
)

// Initializing with additional properties
let newUser = SBUUser(
    user: user, 
    isOperator: true, 
    isMuted: true
)

SBUGlobals

Copy link

SBUGlobals is a global class that provides configurations and variables for Sendbird UIKit. This includes user data like applicationId, accessToken, and currentUser, as well as feature configurations such as imageCompressionRate and isMessageGroupingEnabled. These settings affect the behavior and appearance of the UIKit across your SwiftUI application.

The values in SBUGlobals should be set before using the client app. If changes are required while the app is running, ensure they are updated before the associated features are utilized.

List of properties

Copy link
Properties
NameTypeDescription

accessToken

String?

Specifies the access token of the user (Default: nil)

apiHost

String?

Specifies the API host URL to connect to a specific API server

applicationId

String?

Specifies the application ID from Sendbird dashboard.

currentUser

SBUUser?

Specifies the current User that is type of SBUUser

imageCompressionRate

CGFloat

Specifies the image compression rate value that will be used when sending image (Default: 0.7)

imageResizingSize

CGSize

Specifies the image resizing size value that will be used when sending image (Default: device screen size)

isAVPlayerAlwaysEnabled

Bool

Specifies the audio/video player of file message. If it’s true, AVPlayerViewController is presented. Otherwise, UIDocumentInteractionController is presented (Default: false)

isCustomizedIconResizable

Bool

Specifies the resizable of customized icon image. If it’s false, all customized icon images are never resized (Default: true)

isImageCompressionEnabled

Bool

If this value is enabled, image compression and resizing will be applied when sending a file message (Default: false)

isMessageGroupingEnabled

Bool

If this value is enabled, messages sent at similar times are grouped (Default: false)

isPHPickerEnabled

Bool

If it’s true, uses PHPickerViewController instead of UIImagePickerController when access to the photo library for sending file message.

isTintColorEnabledForCustomizedIcon

Bool

Specifies the Sendbird UIKit uses appropriate tint color options from themes to the customized icon image. If it’s false, all customized icon images used in Sendbird UIKit will ignore tint color options (Default: true)

isUserIdUsedForNickname

Bool

Specifies whether a nickname uses a user ID when there is no user nickname based on the user ID

messageCellConfiguration

SBUMessageCellConfiguration

Specifies the configuration for message cell.

photoLibraryAccessLevel

SBUPhotoAccessLevel

Specifies the level of access to the photo library (Default: .readWrite)

reply

SBUReplyConfiguration

Specifies the configuration for reply.

scrollPostionConfiguration

SBUScrollPostionConfiguration

Specifies the configuration for scroll position.

userMentionConfig

SBUUserMentionConfiguration

Specifies the configuration for user mention.

voiceMessageConfig

SBUVoiceMessageConfiguration

Specifies the configuration for voice message.

wsHost

String?

Specifies the WebSocket host URL to connect to a specific WebSocket server

Note: For a comprehensive list of properties and details, refer to the SBUGlobals official documentation.

Usage Example

Copy link

Below is an example of how to use SBUGlobals in your Swift application:

// Setting user and feature configurations
SBUGlobals.currentUser = SBUUser(
    userId: {USER_ID},
    nickname: {NICKNAME},
    profileURL: "https://example.com/profile.jpg"
)

SBUGlobals.isMessageGroupingEnabled = true
SBUGlobals.imageCompressionRate = 0.8
SBUGlobals.apiHost = "https://custom-api-host.com"
SBUGlobals.accessToken = "ACCESS_TOKEN"
SBUGlobals.photoLibraryAccessLevel = SBUPhotoAccessLevel.addOnly

SBUGlobalCustomParams

Copy link

You can set global parameters used in group channels and open channels across the SwiftUI through various builders of SBUGlobalCustomParams. The values of SBUGlobalCustomParams must be set before the client app is used. If you need to make changes while the client app is running, make sure the values are set before the features are used.

SBUGlobalCustomParams.groupChannelParamsCreateBuilder = { params in
    params?.isDistinct = true
}

SBUAvailable

Copy link

You can see the attributes that are set in the Sendbird application through the SBUAvailable class.

List of properties

Copy link
Properties
NameTypeDescription

multipleFilesMessageFileCountLimit

Int

The maximum number of files that can be selected when sending a message in GroupChannel. This is decided as the minimum value between the count limit set by the server, and the count limit set by Sendbird UIKit.

uploadSizeLimitBytes

Int64

The size limit of a file upload in bytes.

uploadSizeLimitMB

Int64

The size limit of a file upload in MB.

Note: For a comprehensive list of properties and details, refer to the SBUAvailable official documentation.

List of methods

Copy link
Methods
NameParametersReturn TypeDescription

isSupportBroadcastChannel

None

Bool

Checks if the application supports broadcast channels.

isSupportMessageSearch

None

Bool

Checks if the application supports message search.

isSupportOgTag

channelType: ChannelType

Bool

Checks if the application supports Open Graph metadata.

isSupportReactions

None

Bool

Checks if the application supports reactions for Group Channels.

isSupportReactions

for: SBUChannelType

Bool

Checks if the application supports reactions for the given channel type.

isSupportSuperGroupChannel

None

Bool

Checks if the application supports super group channels.

Note: For a comprehensive list of methods and details, refer to the SBUAvailable official documentation.

Usage Example

Copy link

Below is an example of how to use SBUAvailable in your Swift application:

let multipleFilesMessageFileCountLimit = SBUAvailable.multipleFilesMessageFileCountLimit
let uploadSizeLimitBytes = SBUAvailable.uploadSizeLimitBytes
let uploadSizeLimitMB = SBUAvailable.uploadSizeLimitMB

let isBroadcastChannelSupported = SBUAvailable.isSupportBroadcastChannel()
let canSearch = SBUAvailable.isSupportMessageSearch()
let supportsOg = SBUAvailable.isSupportOgTag(channelType: ChannelType.group)
let isSupportReactions = SBUAvailable.isSupportReactions()
let isGroupChannelSupportReactions = SBUAvailable.isSupportReactions(for: SBUChannelType.group)
let isSuperGroupChannelSupportReactions = SBUAvailable.isSupportReactions(for: SBUChannelType.superGroup)
let isSuperGroupChannelSupported = SBUAvailable.isSupportSuperGroupChannel()