Chat UIKit iOS v2
Chat UIKit iOS
Chat UIKit
iOS
Version 2
Sendbird Chat UIKit v2 for iOS is no longer supported as a new version is released. Check out our latest Chat UIKit v3

Group channel

Copy link

This page explains key functions of group channels in Sendbird UIKit for iOS, consisting of how to list channels, chat in a channel, configure channel settings, create a channel, invite users, and list channel members.


List channels

Copy link

The SBUChannelListViewController is a class that is used to get a channel list view. When there is no connection between the client app and Sendbird server, this class is automatically called and reconnects the two. Once the client app is connected to Sendbird server, the class is called and a list of channels in the client app is displayed. In addition the class handles core features including pagination and real-time updates. All chat services built with Sendbird UIKit begin from the channel list.

How to use

Copy link

In the UIKit, you can build a channel list-based chat service without the need for complicated implementation through the SBUChannelListViewController class. Use the following code to list channels in a view.

Note: You can initialize the SBUChannelListViewController by setting the SBDChannelListQuery object. Otherwise, the default values are used.

SwiftObjective-C
// Case 1: Default initialize.
let channelListVC = SBUChannelListViewController()
let naviVC = UINavigationController(rootViewController: channelListVC)
present(naviVC, animated: true)

// Case 2: Using channelListQuery.
let listQuery = SBDGroupChannel.createMyGroupChannelListQuery()
listQuery?.includeEmptyChannel = false
listQuery?.includeFrozenChannel = true

let channelListVC = SBUChannelListViewController(channelListQuery: listQuery)
let naviVC = UINavigationController(rootViewController: channelListVC)
present(naviVC, animated: true)

Note: At this point, you can confirm if the service is working by running your app.

Components and features

Copy link

The components of the SBUChannelListViewController class include Header and List. The List is an area where the UITableView shows channel information using the SBUChannelCell. The features of the SBUChannelListViewController include:

List of features

Copy link
FeatureDescription

Enter channel

Enters a channel by selecting a channel cell on the list.

Notifications on and off

Turns push notifications on and off by swiping a cell.

Create channel

Creates a channel by using the channel type selector if the application uses a Supergroup channel feature. If not, go directly to the create channel page.

Channel type selector

Allows a user to select a channel type to create.

Leave channel

Leaves a channel by swiping a cell.

Back and dismiss

Triggers a pop view and dismisses an action.

Edit components

Copy link

The following table lists a set of customizable properties and methods of the SBUChannelListViewController class.

List of properties

Copy link
Property nameTypeDescription

channelList

SBDGroupChannel

An object that contains a list of channels which are synchronized with the server.

channelListQuery

SBDGroupChannelListQuery

A query that retrieves a list of channels and change logs of channels.

List of methods

Copy link
MethodDescription

register(channelCell:nib:)

Access level: public
Registers or edits an existing channel cell. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The channelCell should be a class type that inherits the SBUBaseChannelCell.

register(customCell:nib:)

Access level: public
Registers a channelCell with a custom type. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The channelCell should be a class type that inherits the SBUBaseChannelCell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the SBUChannelListViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the SBUChannelListViewController. You can customize the view by overriding and implementing this method.

showChannel(channelUrl:)

Access level: open
Displays a channel view. You can customize the SBUChannelViewController class by overriding and implementing this method.

showCreateChannelTypeSelector()

Access level: open
Calls the showCreateChannel(type:) method with the available channel types. You can customize the createChannelTypeSelector or createChannel action by overriding and implementing this method.

showCreateChannel(type:)

Access level: open (Default: .group)
Displays all available channel types that can be created. You can customize the SBUCreateChannelViewController class by overriding and implementing this method.

changePushTriggerOption(option:channel:completionHandler:)

Access level: public
Changes a notification trigger option for a channel.

leaveChannel(channel:)

Access level: public
Leaves a channel.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

ChannelList_Header_Title

The title of the viewController.

ChannelList_Last_File_Message

A text displayed when the last message in a channel is a SBDFileMessage type.

Note : A set of common strings isn't included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons. The iconSet includes:

  • iconActionLeaveLight, iconActionNotificationOffLight, iconActionNotificationOnLight, iconCreate, iconMute

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBDChannelListviewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle, SBDConnectionDelegate

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Channel type selector

Copy link

Channel type selector exposes all the available channel types a user can create. If the Supergroup channel feature is turned on for the app, this selector will display channel two types: Group and Supergroup.
Use the isSupportSuperGroupChannel() method of the SBUAvailable class to see what channel types are supported for your application.

View customization

Copy link

In order to customize the Channel type selector, you need to implement a custom view through the SBUCreateChannelTypeSelectorProtocol and SBUCreateChannelTypeSelectorDelegate classes first.
If you implement the view through the SBUCreateChannelTypeSelectorProtocol class, the SBUChannelListViewController calls the show() and dismiss() actions if necessary. Another way to implement the custom view is to override the showCreateChannelTypeSelector() method.
Once implemented, set the custom view to the createChannelTypeSelector in the SBUChannelListViewController.

- SBUCreateChannelTypeSelectorProtocol

Copy link

The following table lists properties of the SBUCreateChannelTypeSelectorProtocol class.

Property nameDescription

show()

Shows a selector view.

dismiss()

Makes a selector view disappear.

Action customization

Copy link

You can customize an action by overriding the methods of the SBUCreateChannelTypeSelectorDelegate class in the SBUChannelListViewController class.

Note : The didSelectCreateGroupChannel(), didSelectCreateSuperGroupChannel() methods of the SBUCreateChannelTypeSelectorDelegate class calls the showCreateChannel(type:) method. But if you have customized the SBUCreateChannelViewController class, you can implement the custom action by overriding the showCreateChannel(type:) method.

- SBUCreateChannelTypeSelectorDelegate

Copy link

The following table lists properties of the SBUCreateChannelTypeSelectorDelegate class.

Property nameDescription

didSelectCloseSelector()

Notifies the SBUchannelListViewController when a user closes the selector.

didSelectCreateGroupChannel()

Notifies the SBUchannelListViewController when a user selects a group channel option on the selector.

didSelectCreateSuperGroupChannel()

Notifies the SBUchannelListViewController when a user selects a Supergroup channel option on the selector.

The SBUChannelListViewController class uses two of the SBUTheme, which are the SBUChannelCellTheme and the SBUChannelListTheme. The SBUChannelCellTheme is used for the SBUChannelCell while the SBUChannelListTheme is used for all elements of the SBUChannelListViewController but the SBUChannelCell. Theme properties cannot be accessed directly and should be customized only through the SBUTheme. Then you should call the setupStyle() afterwards in order to apply any changes you make through the SBUTheme.

Set a custom theme

Copy link

You can customize themes through the SBUTheme.setChannelList as below:

SwiftObjective-C
let channelListTheme = SBUChannelListTheme(
    leftBarButtonTintColor: SBUColorSet.primary300
    ...

)

let channelCellTheme = SBUChannelCellTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

SBUTheme.setChannelList(channelListTheme: channelListTheme,
            channelCellTheme: channelCellTheme)

Note : You should call the setupStyle() method to update your user interface.

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the themes prior to viewController initialization. The following code shows how to customize the elements of the theme.

SwiftObjective-C
// Channel list theme.
SBUTheme.channelListTheme.backgroundColor = SBUColorSet.background100

// Channel cell theme.
SBUTheme.channelCellTheme.backgroundColor = SBUColorSet.background100

Note : You should call the setupStyle() method to update your user interface.

- SBUChannelListTheme

Copy link

The SBUChannelListTheme object has properties used in the SBUChannelListViewController.

CategoryPropertyDescription

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Status bar

statusBarStyle

The style of the status bar.

View

backgroundColor

The background color of the channel list view.

Table view

alertBackgroundColor

The background color of the alert.

Table view

notificationOnBackgroundColor

The background color of the notification-on.

Table view

notificationOnTintColor

The tint color of the notification-on.

Table view

notificationOffBackgroundColor

The background color of the notification-off.

Table view

notificationOffTintColor

The tint color of the notification-off.

Table view

leaveBackgroundColor

The background color of the leave channel button.

Table view

leaveTintColor

The tint color of the leave channel button.

- SBUChannelCellTheme

Copy link

The SBUChannelCellTheme object has properties used in the SBUChannelCell.

CategoryPropertyDescription

View

backgroundColor

The background color of the cell.

View

separatorLineColor

The color of the separator line.

Title

titleFont

The font of the title element.

Title

titleTextColor

The text color of the title element.

Member count

memberCountFont

The font of the member count element.

Member count

memberCountTextColor

The text color of the member count element.

Last updated time

lastUpdatedTimeFont

The font of the last-updated time element.

Last udated time

lastUpdatedTimeTextColor

The text color of the last-updated time element.

Message

messageFont

The font of the message element.

Message

messageTextColor

The text color of the message element.

Unread count

unreadCountBackgroundColor

The background color of the unread message count element.

Unread count

unreadCountFont

The font of the unread message count element.

Unread count

unreadCountTextColor

The text color of the unread message count element.

Channel State

freezeStateTintColor

The tint color of the freeze state mark element.


Create a channel

Copy link

In the UIKit, you can create a channel through the SBUCreateChannelViewController class with a group of selected users. The class also affects the SBUUserCell class which shows a user list and the user list is organized and displayed according to the setting of pagination. If you don’t have a separate list of users you wish to add to your application, all the users who are using your chat service are displayed in the user list by default.

By default the name and cover image of the channel are also given when the channel is created. The channel will be the list of nickname of channel members, and its cover image will be created using the profileimage of those members.

Note : Simply setting your chat service to be based on the channel list can seamlessly lead users to the Create channel view. Once a new channel is successfully created, a channel view will appear immediately for the user. If the channel type is set during initialization, a new channel is created as the selected type. However, if you create a channel through the createChannel(params:) method with parameters, the channel type information must be set in the parameter again. And, the user who creates a new channel becomes an operator of the channel by default.

How to use

Copy link

You can create a channel by simply calling the SBUCreateChannelViewController class. Use the following code to create a new channel.

SwiftObjective-C
let createChannelVC = SBUCreateChannelViewController(type: .group)
let naviVC = UINavigationController(rootViewController: createChannelVC)
present(naviVC, animated: true)

Using your own user list

Copy link

You can also create a channel with a list of users you specifically selected. To do so, an array of SBUUser objects should be injected.

Note : You can convert the SBDUser objects from the Chat SDK to the SBUUser as they are compatible.

Use the following code to create a channel with a preset list of users.

SwiftObjective-C
let sbdUser: SBDUser = ...  // Chat SDK's user-related class
let users: [SBUUser] = [
    SBUUser(userId: {USER_ID}),
    SBUUser(userId: {USER_ID2}, nickname: {NICKNAME}, profileUrl: nil),
    SBUUser(userId: {USER_ID3}, nickname: nil, profileUrl: {PROFILE_URL}),
    SBUUser(user: sbdUser),
    ...

]

let createChannelVC = SBUCreateChannelViewController(users: users)
...

// If need to pagination, check below:
createChannelVC.loadNextUserList(reset: false, users: nextPageUsers)

Components and features

Copy link

The SBUCreateChannelViewController is composed of a list of users who can be invited to the newly created channel.

Edit components

Copy link

The following table lists the customizable properties and methods of the SBUCreateChannelViewController class.

List of methods

Copy link
MethodDescription

register(userCell:nib:)

Access level: public
Registers or edits an existing user cell. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it won't add Nib to the cell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

createChannel(userIds:)

Access level: public
Creates a channel with specific users. If the channel type was set during the class initialization and you use this method to create a channel, the channel type of the new channel is automatically set to the preset type.

createChannel(params:)

Access level: public
Creates a channel with channelParams.
If you use this method to create a channel, the channel type of the new channel must be set in the parameter even if a specific channel type was set during the class initialization.

loadNextUserList(reset:users:)

Access level: public
Retrieves a list of users. By default, you can retrieve 20 users at once. Use the reset option to initialize the list and send a new request. For the customized user list, pass it through the users parameter.

nextUserList()

Access level: open
Retrieves the remaining user list. You can override and implement this method for a customized list.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

CreateChannel_Header_Title

The title of the viewController.

CreateChannel_Create (count)

A text for the Create button on the navigation bar.

Note : A set of common string is not included in the list. See the Common resources page's StringSet section.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons.

Note : A set of common icons is not included in the list. See the Common resources page's IconSet section.

Customize the class

Copy link

You can subclass and customize the SBUCreateChannelViewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle, loadNextUserList()

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Set a custom theme

Copy link

You can customize themes through the SBUTheme.setUserList as below:

SwiftObjective-C
let userListTheme = SBUUserListTheme(
    navigationBarTintColor: SBUColorSet.background100
    ...

)

let userCellTheme = SBUUserCellTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

SBUTheme.setUserList(userListTheme: userListTheme, userCellTheme: userCellTheme)

Note : You should call the setupStyle() method to update your user interface.

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the themes prior to the viewController initialization. The following code shows how to customize the elements of the theme.

SwiftObjective-C
// user list theme.
SBUTheme.userListTheme.navigationBarTintColor = SBUColorSet.background100

// user cell theme.
SBUTheme.userCellTheme.backgroundColor = SBUColorSet.background100

- SBUUserListTheme

Copy link

The SBUUserListTheme object has properties used in the following classes: SBUCreateChannelViewController, SBUInviteUserViewController and SBUMemberListViewController.

List of properties

Copy link
CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Navigation bar

rightBarButtonSelectedTintColor

The tint color to apply to the button at the right side of the navigation bar when selected.

Status bar

statusBarStyle

The style of the status bar.

Cell

cellTextFont

The text font of the cell.

- SBUUserCellTheme

Copy link

The SBUUserCellTheme object has properties used in the SBUUserCell.

CategoryPropertyDescription

View

backgroundColor

The background color of the view.

View

separateColor

The color of the separator.

Check box

checkboxOnColor

The color to apply to a checkbox element when checked.

Check box

checkboxOffColor

The color to apply to a checkbox element when unchecked.

User

userNameTextColor

The text color of the user name element.

User

userNameFont

The text font of the user name element.

User

userPlaceholderBackgroundColor

The background color of the user name element's placeholder.

User

userPlaceholderTintColor

The tint color of the user name element's placeholder.


Chat in a channel

Copy link

UIKit allows 1-on-1 and 1-to-N chats through private and public group channels. It also provides a Supergroup channel to facilitate a more stable chat environment for a larger number of users. They can be easily managed without the need for complex implementation.

UIKit supports plain text messages, file messages, and media content such as photos and videos. Once sent, those messages are grouped by time and date, displaying the time by minute. In addition, all messages in open channels are cached using memory, and messages that failed to be sent are only kept within the active channel object.

Note : Simply setting your chat service to be based on the channel list can seamlessly lead users to the Channel view. As for the function that groups messages based on their sent time can be turned on and off through the UsingMessageGrouping property in the SBUGlobals class.

How to enable chat through SBUChannelViewController

Copy link

All chat services built with Sendbird UIKit for iOS begin from the channel list. You can build a channel-based chat service by calling the SBUChannelViewController class. It uses the SBUAdminMessageCell, SBUUserMessageCell and SBUFileMessageCell to display information.

The SBUChannelViewController class also is in charge of an auto connection to Sendbird server and internal logics to handle core features of UIKit such as pagination and real-time updates.

Note: You can initialize the SBUChannelViewController by setting the ChannelUrl or SBDGroupChannel object. And, if you have own SBDMessageListParams object, please set them together. If not set, it is used as the default value.

Use the following code to enable users to chat in a channel view.

SwiftObjective-C
// Case 1: Using channel url.
let channelVC = SBUChannelViewController(channelUrl: {CHANNEL_URL})
let naviVC = UINavigationController(rootViewController: channelVC)
present(naviVC, animated: true)

// Case 2: Using channel object.
let channelVC = SBUChannelViewController(channel: {CHANNEL})
let naviVC = UINavigationController(rootViewController: channelVC)
present(naviVC, animated: true)

// Case 3: Using messageListParams object as well.
let params = SBDMessageListParams()
params.includeMetaArray = true
params.includeReactions = true
let channelVC = SBUChannelViewController(channel: {CHANNEL}, messageListParams: params)
let naviVC = UINavigationController(rootViewController: channelVC)
present(naviVC, animated: true)

// Case 4: Setting a specific timestamp to be the reference point of message retrieval.
let params = SBDMessageListParams()
params.includeMetaArray = true
params.includeReactions = true
let channelVC = SBUChannelViewController(channelUrl: {CHANNEL_URL},
                                        startingPoint: {STARTING_POINT_TIMESTAMP},
                                        messageListParams: params)
let naviVC = UINavigationController(rootViewController: channelVC)
present(naviVC, animated: true)

Global usage

Copy link

You can directly take a user to a specific channel from notifications through the SBUMain.moveToChannel(channelUrl:) method. This method is used to find the destination channel to put the user in or even to create one if there is no applicable channel.

SwiftObjective-C
// Set it `true` to use based on channel list, false to use based on channel.
let basedOnChannelList = true
SBUMain.moveToChannel(channelUrl: {CHANNEL_URL}, basedOnChannelList: basedOnChannelList)

Components and features

Copy link

The components of the SBUChannelViewController class include Header, List, and messageInput. The List is an area where the UITableView displays messages in the channel using the SBUUserMessageCell, SBUFileMessageCell, and SBUAdminMessageCell.

The features of the SBUChannelViewController class include:

List of features

Copy link
FeatureDescription

Message input view

Allows users to send messages, image/video or files.

New message information

Displays a notification when a new message arrives.

Last seen time

Displays a member’s last seen time. This is only available for 1-on-1 channels.

Send status

Displays message send status such as success, failed, and sending.

Delivery receipt status

Displays message delivery receipt status.

Read receipt status

Displays message receipt status.

Message copying

Allows users to copy a message. (text only)

Message editing

Allows users to edit a message. (own message only)

Message deleting

Allows users to delete a message. (own message only)

Retry send message

Allows users to resend a failed message.

Channel settings menu

Navigates to the Setting view from the NavigationBar.

Back and dismiss

Returns to the previous view from the NavigationBar.

State banner

Displays the status of the channel in the top banner. Currently, the banner can only display the frozen state unless you customize it.

Edit components

Copy link

The following table lists a set of customizable properties and methods of the SBUChannelViewController class.

List of properties

Copy link
Property nameTypeDescription

channel

SBDGroupChannel

An object that represents the channel.

channelName

String

The customized title of the channel.

messageList

SBDBaseMessage

An object that contains a list of messages which are synchronized with the server.

resendableMessages

String:SBDBaseMessage

(Deprecated) An object that contains pending and failed messages which can be resent.

messageInputView

SBUMessageInputView

The customized message input view.

newMessageInfoView

SBUNewMessageInfo

The customized new message info view.

messageListParams

SBDMessageListParams

A set of parameters that retrieves a list and change logs of the messages.

startingPoint

Int64

A start point of the message list which can be set through the init(channelUrl:startingPoint:messageListParams:) constructor. To start from the latest message, set it to nil.

useRightBarButtonItem

Bool

A flag that determines whether to use the right bar button item or not.

highlightInfo

SBUHighlightMessageInfo

A SBUHighlightMessageInfo object to specify a message to be highlighted.

List of methods

Copy link
MethodDescription

register(adminMessageCell:nib:)

Access level: public
Registers or edits an admin message cell when the message is a SBDAdminMessage type. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The cell should be a class type that inherits the SBUBaseMessageCell.

register(fileMessageCell:nib:)

Access level: public
Registers or edits a file message cell when the message is a SBDFileMessage type. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The cell should be a class type that inherits theSBUBaseMessageCell.

register(userMessageCell:nib:)

Access level: public
Registers or edits a user message cell when the message is a SBDUserMessage type. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The cell should be a class type that inherits the SBUBaseMessageCell.

register(customMessageCell:nib:)

Access level: public
Registers or edits a custom message cell when the message has a custom type. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell. The cell should be a class type that inherits the SBUBaseMessageCell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

showChannelSettings()

Access level: open
Displays the channel settings menu. You can customize the channelSettingsViewController by overriding and implementing this method.

setTapGestureHandler(_ cell:message:)

Access level: open
Specifies what gesture to be used for a tap. You can customize the tap gesture to the cell by overriding and implementing this method.

setLongTapGestureHandler(_ cell:message:indexPath:)

Access level: open
Specifies what gesture to be used for a long tap. You can customize the long tap gesture to the cell by overriding and implementing this method.

sendUserMessage(text:)

Access level: public
Sends a user message.

sendUserMessage(messageParams:)

Access level: public
Sends a user message with SBDUserMessageParams.

sendFileMessage(fileData:fileName:mimeType:)

Access level: public
Sends a file message with file data, file name, and mime type.

sendFileMessage(messageParams:)

Access level: public
Sends a file message with SBDFileMessageParams.

resendMessage(failedMessage:)

Access level: public
Resends a failed message.

updateUserMessage(message:text:)

Access level: public
Updates a user message.

updateUserMessage(message:messageParams:)

Access level: public
Updates a user message with SBDUserMessageParams.

deleteMessage(message:)

Access level: public
Deletes a message.

Note : To customize the messageInputView or newMessageInfoView, you should subclass the SBUMessageInputView or SBUNewMessageInfo class, respectively. Also, if the MessageInputView indicates that the channel is frozen or the member is muted in the channel, the channel state can be changed through the setFrozenModeState(_ isFrozen:) or setMutedModeState(_ isMuted:) method of the SBUMessageInputView.
In the case where both Frozen and Muted states coexist in a channel, only the Frozen state will be displayed in the view.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

Channel_Name_Default

The default channel name.

Channel_New_Message (count)

A text for new message popup.

Channel_New_Message_File (%@)

A text for file message upload completion.

Channel_Success_Download_file

A text for file save completion.

Channel_Header_LastSeen (timestamp)

A text for a member’s last seen time.

Channel_Header_Typing (typingMembers)

A text for a member’s typing status.

MessageInput_Text_Placeholder

A placeholder for a message input box.

MessageInput_Text_Unavailable

A placeholder to indicate that a message can't be entered in the input box when the channel is frozen.

MessageInput_Text_Muted

A placeholder to indicate that a message can't be entered in the input box when the user is blocked.

Message_Edited

A text for message edit pop-up.

Message_System

A text for system message type.

Message_Unknown_Title

A title for an unknown message.

Message_Unknown_Description

A description for an unknown message.

Channel_State_Banner_Frozen

A text to be displayed in the state banner for a frozen channel.

Note : A set of common string is not included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons. The iconSet includes:

  • iconCopy, iconEdit, iconInfo, iconNewMessage, iconAdd, iconSend, iconDelivered, iconErrorFilled, iconRead, iconSent, iconSpinnerSmall, iconFileAudio, iconFileDocument, iconGif, iconPlay

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBUChannelViewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle, SBUMessageInputViewDelegate, SBUFileViewerDelegate, SBDConnectionDelegate

If you wish to create and implement a custom message cell, you must inherit the SBUBaseMessageCell class. To register your custom message cell to be shown on the List component of the channel view, use the register(customMessageCell:nib:) function.

You can also change a cell's Identifier by overriding the generateCellIdentifier function. By default, the cell's Identifier takes on the name of the class.

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

To display messages, the SBUChannelViewController uses two views and three themes. Two views include the SBUBaseMessageCell and the SBUMessageInputView, and three themes are the SBUChannelTheme, SBUMessageCellTheme, and SBUMessageInputTheme in the SBUTheme.

The overall elements of the SBUChannelViewController are managed through the SBUChannelTheme while the SBUBaseMessageCell uses the SBUMessageCellTheme to show messages in the view and the SBUMessageInputView uses the SBUMessageInputThemefor the design of the message input box in the view.

All three themes mentioned above can be customized through the SBUTheme but you should call the setupStyle() afterwards in order to apply any changes you made.

Set a custom theme

Copy link

You can customize the channel theme through the SBUTheme.setChannel as below:

Note : You should call the setupStyle() method afterwards in order to apply any changes you made.

SwiftObjective-C
let channelTheme = SBUChannelTheme(
    navigationBarTintColor: SBUColorSet.primary300
    ...

)

let messageCellTheme = SBUMessageCellTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

let messageInputTheme = SBUMessageInputTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

SBUTheme.setChannel(channelTheme: channelTheme,
        messageCellTheme: messageCellTheme,
        messageInputTheme: messageInputTheme)

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the themes prior to viewController initialization. The following code shows how to customize the elements of the theme.

Note : You should call the setupStyle() method afterwards in order to apply any changes you made.

SwiftObjective-C
// Channel theme.
SBUTheme.channelTheme.backgroundColor = SBUColorSet.background100
...

// Message cell theme.
SBUTheme.messageCellTheme.backgroundColor = SBUColorSet.background100
...

// Message input theme.
SBUTheme.messageInputTheme.backgroundColor = SBUColorSet.background100
...

- SBUChannelTheme

Copy link

The SBUChannelTheme object has properties used in the SBUChannelViewController.

CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Status bar

statusBarStyle

The style of the status bar.

View

backgroundColor

The background color of the channel view.

Alert

removeItemColor

The color of the item remove alert.

Alert

cancelItemColor

The color of the item cancel alert.

Alert

alertRemoveColor

The color of the remove action's button.

Alert

alertCancelColor

The color of the cancel action's button.

Menu

menuTextColor

The text color of the menu.

State banner

channelStateBannerFont

The text font of the state banner.

State banner

channelStateBannerTextColor

The text color of the state banner.

State banner

channelStateBannerBackgroundColor

The background color of the state banner.

- SBUMessageInputTheme

Copy link

The SBUMessageInputTheme object has properties used in the SBUChannelViewController.

CategoryPropertyDescription

View

backgroundColor

The background color of the message input view.

Text field

textFieldBackgroundColor

The background color of the input field.

Text field

textFieldPlaceholderColor

The color of the placeholder in the input field.

Text field

textFieldPlaceholderFont

The font of the placeholder in the input field.

Text field

textFieldDisabledColor

The color of the placeholder to indicate that text can't be entered in the input field.

Text field

textFieldTintColor

The tint color of the text in the input field.

Text field

textFieldTextColor

The color of the text in the input field.

Text field

textFieldBorderColor

The border color of the input field.

Button

buttonTintColor

The tint color of the add, cancel, and save buttons.

Button

buttonDisabledTintColor

The tint color of the add button when entering text is not available.

Button

cancelButtonFont

The font of the cancel button.

Button

saveButtonFont

The font of the save button.

Button

saveButtonTextColor

The color of the text on the save button.

- SBUMessageCellTheme

Copy link

The SBUMessageCellTheme object has properties used in the SBUChannelViewController.

CategoryPropertyDescription

View

backgroundColor

The background color of the cell.

View

leftBackgroundColor

The background color of the left side of the cell.

View

rightBackgroundColor

The background color of the right side of the cell.

View

leftPressedBackgroundColor

The background color to apply to the button at the left side when pressed.

View

rightPressedBackgroundColor

The background color to apply to the button at the right side when pressed.

Date label

dateFont

The font of the date element.

Date label

dateTextColor

The text color of the date element.

Date label

dateBackgroundColor

The background color of the date element.

User

userNameFont

The font of the user name.

User

userNameTextColor

The text color of the user name element.

User

userPlaceholderBackgroundColor

The background color of the user name element's placeholder.

User

userPlaceholderTintColor

The tint color of the user name element's placeholder.

Title label

timeFont

The font of the time element.

Title label

timeTextColor

The text color of the time element.

Message state

pendingStateColor

The color to apply when the state of a message is pending.

Message state

failedStateColor

The color to apply when the state of a message is failed.

Message state

succeededStateColor

The color to apply when the state of a message is succeeded.

Message state

readReceiptStateColor

The color of the read receipt state element.

Message state

deliveryReceiptStateColor

The color of the delivery receipt state element.

User message

userMessageFont

The font to apply to a user message.

User message

userMessageLeftTextColor

The text color to apply to a user message displayed on the left of the channel view.

User message

userMessageLeftEditTextColor

The text color to indicate edited a user message displayed on the left of the channel view.

User message

userMessageRightTextColor

The text color to apply to a user message displayed on the right of the channel view.

User message

userMessageRightEditTextColor

The text color to indicate an edited user message displayed on the right of the channel view.

File message

fileIconBackgroundColor

The background color of the file icon

File message

fileIconColor

The color of the file icon.

File message

fileMessageNameFont

The text font of the file message name element.

File message

fileMessageLeftTextColor

The text color of the left side of a file message.

File message

fileMessageRightTextColor

The text color of the right side of a file message.

File message

fileMessagePlaceholderColor

The text color of a file message's placeholder.

Admin message

adminMessageFont

The text font of an admin message.

Admin message

adminMessageFont

The text color of an admin message.

Unknown message

unknownMessageDescFont

The text font of an unknown message.

Unknown message

unknownMessageDescTextColor

The text color of an unknown message.


Invite users or promote users to operators

Copy link

In the UIKit, you can invite users to a specific group channel or promote a user to an operator of a specific channel according to the type set by the SBUInviteUserViewController class. The ViewController uses the SBUUserCell class to display a list of members except the ones who are already in the channel. The same SBUUserCell class is also used when inviting a user or appoint a user as an operator of a specific group channel.

Unless you have a separate list of users you specifically selected, all users who are registered to your service appear in the user list by default.

Note : Simply setting your chat service to be based on either the channel list, channels, channel settings or member list can seamlessly lead users to the Invite users view. For the view, you can set inviteUserType to use the desired function among user invitation and promote to operator then initializing the SBUInviteUserViewController class.

How to use

Copy link

Invite users to a group channel with a simple implementation through the SBUInviteUserViewController class.

Note : You can initialize the SBUInviteUserViewController class by setting the ChannelUrl or SBDGroupChannel object.

Use the following code to invite a user to a channel.

SwiftObjective-C
// Case 1.1: Invite user using channel url.
let inviteUserVC = SBUInviteUserViewController(channelUrl: {CHANNEL_URL}, type: .users)
let naviVC = UINavigationController(rootViewController: inviteUserVC)
present(naviVC, animated: true)

// Case 1.2: Invite user using channel object.
let inviteUserVC = SBUInviteUserViewController(channel: {CHANNEL}, type: .users)
let naviVC = UINavigationController(rootViewController: inviteUserVC)
present(naviVC, animated: true)

// Case 2.1: Promote user to operator using channel url.
let promoteVC = SBUInviteUserViewController(channelUrl: {CHANNEL_URL}, type: .operators)
let naviVC = UINavigationController(rootViewController: promoteVC)
present(naviVC, animated: true)

// Case 2.2: Promote user to operator using channel object.
let promoteVC = SBUInviteUserViewController(channel: {CHANNEL}, type: .operators)
let naviVC = UINavigationController(rootViewController: promoteVC)
present(naviVC, animated: true)

Using your own user list

Copy link

You can also invite a list of users you specifically selected. To do so, an array of SBUUser objects should be injected.

Note : You can convert the SBDUser objects from the Chat SDK to the SBUUser as they are compatible.

Use the following code to invite a list of users you specifically selected to a channel.

SwiftObjective-C
let users: [SBUUser] = [
    SBUUser(userId: {USER_ID}),
    SBUUser(userId: {USER_ID2}, nickname: {NICKNAME}, profileUrl: nil),
    SBUUser(userId: {USER_ID3}, nickname: nil, profileUrl: {PROFILE_URL}),
    ...

]

let inviteUserVC = SBUInviteUserViewController(channel: {CHANNEL}, users: users)
...

// If need to pagination, add the nextUserList using the code below:
inviteUserVC.loadNextUserList(reset: false, users: nextPageUsers)

Components and features

Copy link

The SBUInviteUserViewController is composed of a list of users who can be invited to existing channels.

Edit components

Copy link

The following table lists the customizable properties and methods of the SBUInviteUserViewController class.

List of methods

Copy link
MethodDescription

register(userCell:nib:)

Access level: public
Registers a new user cell or edits an existing one. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

inviteUsers()

Access level: public
Invites a list of selected users to the channel.

inviteUsers(userIds:)

Access level: public
Invites users to the channel with userIds that you directly injected.

promoteToOperators()

Access level: public
Promotes channel members as operator with selected userIds.

promoteToOperators(memberIds:)

Access level: public
Promotes channel members as an operator with memberIds that you directly injected.

loadNextUserList(reset:users:)

Access level: public
Retrieves a list of users. By default, you can retrieve 20 users at once. Use the reset option to initialize the list and send a new request. For a customized user list, pass it through the users parameter.

nextUserList()

Access level: open
Retrieves the remaining user list. You can override and implement this method for a customized list.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

InviteChannel_Header_Title

The title of the ViewController.

InviteChannel_Header_Select_Members

A text for Select members.

InviteChannel_Invite(%d)

A text for the Invite button in the navigation bar.

InviteChannel_Add(%d)

A text for the Add button in the navigation bar.

Note : A set of common strings isn't included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons.

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBUInviteUserViewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle, loadNextUserList()

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Set a custom theme

Copy link

You can customize themes through the SBUTheme.setUserList as below:

SwiftObjective-C
let userListTheme = SBUUserListTheme(
    navigationBarTintColor: SBUColorSet.background100
    ...

)

let userCellTheme = SBUUserCellTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

SBUTheme.setUserList(userListTheme: userListTheme, userCellTheme: userCellTheme)

Note : You should call the setupStyle() method to update your user interface.

Edit theme elements

Copy link

Themes can be customized through the SBUTheme class. It is recommended to change the themes prior to the viewController initialization. The following code shows how to customize the elements of the theme.

SwiftObjective-C
// User list theme.
SBUTheme.userListTheme.navigationBarTintColor = SBUColorSet.background100

// User cell theme.
SBUTheme.userCellTheme.backgroundColor = SBUColorSet.background100

Note : You should call the setupStyle() method to update your user interface.

- SBUUserListTheme

Copy link

The SBUUserListTheme object has properties used in the following classes: SBUCreateChannelViewController, SBUInviteUserViewController and SBUMemberListViewController.

List of properties

Copy link
CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Navigation bar

rightBarButtonSelectedTintColor

The tint color to apply to the button at the right side of the navigation bar when selected.

Cell

cellTextFont

The text font of the cell.

- SBUUserCellTheme

Copy link

The SBUUserCellTheme object has properties used in the SBUUserCell.

CategoryPropertyDescription

View

backgroundColor

The background color of the view.

View

separateColor

The color of the separator.

Check box

checkboxOnColor

The color to apply to a checkbox element when checked.

Check box

checkboxOffColor

The color to apply to a checkbox element when unchecked.

User

userNameTextColor

The text color of the user name element.

User

userNameFont

The font of the user name element.


List channel members

Copy link

In UIKit, you can retrieve the list of members in a specific group channel through the SBUMemberListViewController class. This class displays a list of channel members, operators, muted members, and banned members using the SBUUserCell class.

Note : Simply setting your chat service to be based on either the channel list, channels, or channel settings can seamlessly lead users to the Member list view.

How to use

Copy link

You can get the list of members in a specific channel by simply calling the SBUMemberListViewController class.

Note : You can initialize the SBUMemberListViewController class by setting a ChannelUrl, SBDGroupChannel or ChannelMemberListType object.

Use the following code to get the member list of a channel.

SwiftObjective-C
// Case 1: Using channel url.
let memberListVC = SBUMemberListViewController(channelUrl: {CHANNEL_URL}, type: .channelMembers)
let naviVC = UINavigationController(rootViewController: memberListVC)
present(naviVC, animated: true)

// Case 2: Using channel object.
let memberListVC = SBUMemberListViewController(channel: {CHANNEL}, type: .channelMembers)
let naviVC = UINavigationController(rootViewController: memberListVC)
present(naviVC, animated: true)

Components and features

Copy link

The SBUMemberListViewController is composed of different types of member list.

TypeDescription

.channelMembers

A list of members in the channel.

.operators

A list of operators in the channel.

.mutedMembers

A list of members muted in the channel.

.bannedMembers

A list of members banned from the channel.

Note: The Add button on the top right is displayed only when ChannelMemberListType is .channelMembers or .operators.

Edit components

Copy link

The following table lists the customizable properties and method of the SBUMemberListViewController class.

List of methods

Copy link
MethodDescription

register(userCell:nib:)

Access level: public
Registers a new user cell or edits an existing one. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

showInviteUser()

Access level: open
Displays the list of users who can be invited. You can customize the inviteUserViewController by overriding and implementing this method.

resetMemberList()

Access level: public
Reloads the member list.

loadNextMemberList(reset:members:)

Access level: public
Loads the member list of the type set during the class initialization. Use the reset option to initialize the list and send a new request. For a customized member list, pass it through the members parameter.

nextMemberList()

Access level: open
Retrieves the remaining member list. You can override and implement this method for a customized list.

loadMembers()

Access level: public
Gets member information directly from the channel in the type of GroupChannel.

promoteToOperator(member:)

Access level: public
Promotes the member as an operator.

dismissOperator(member:)

Access level: public
Dismisses the operator as a member.

mute(member:)

Access level: public
Mutes the member.

unmute(member:)

Access level: public
Unmutes the member.

ban(member:)

Access level: public
Bans the member.

unban(member:)

Access level: public
Unbans the member.

setMoreMenuActionHandler(member:)

Access level: open
Sets the cell's more* menu button action.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

MemberList_Header_Title

The title of the ViewController.

MemberList_Me

A text to indicate which user name belongs to the user themselves.

MemberList_Promote_Operator

A text for Promote to operator

MemberList_Dismiss_Operator

A text for Dismiss operator

MemberList_Mute

A text for Mute

MemberList_Unmute

A text for Unmute

MemberList_Ban

A text for Ban

MemberList_Unban

A text for Unban this member

MemberList_Title_Members

A text for Members

MemberList_Title_Operators

A text for Operators

MemberList_Title_Muted_Members

A text for Muted members

MemberList_Title_Banned_Members

A text for Banned members

Note : A set of common strings isn't included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons.

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBUMemberListViewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle, onClickInviteUser()

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Set a custom theme

Copy link

You can customize themes through the SBUTheme.setUserList as below:

Note : You should call the setupStyle() method afterwards in order to apply any changes you made.

SwiftObjective-C
let userListTheme = SBUUserListTheme(
    navigationBarTintColor: SBUColorSet.background100
    ...

)

let userCellTheme = SBUUserCellTheme(
    backgroundColor: SBUColorSet.background100
    ...

)

SBUTheme.setUserList(userListTheme: userListTheme, userCellTheme: userCellTheme)

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the theme prior to the viewController initialization. The following code shows how to customize the elements of the theme.

Note : You should call the setupStyle() method afterwards in order to apply any changes you made.

SwiftObjective-C
// User list theme.
SBUTheme.userListTheme.navigationBarTintColor = SBUColorSet.background100

// User cell theme.
SBUTheme.userCellTheme.backgroundColor = SBUColorSet.background100

- SBUUserListTheme

Copy link

The SBUUserListTheme object has properties used in the following classes: SBUCreateChannelViewController, SBUInviteUserViewController and SBUMemberListViewController.

List of properties

Copy link
CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Navigation bar

rightBarButtonSelectedTintColor

The tint color to apply to the button at the right side of the navigation bar when selected.

Cell

cellTextFont

The text font of the cell

- SBUUserCellTheme

Copy link

The SBUUserCellTheme object has properties used in the SBUUserCell.

CategoryPropertyDescription

View

backgroundColor

The background color of the view.

View

separateColor

The color of the separator.

Check box

checkboxOnColor

The color to apply to a checkbox element when checked.

Check box

checkboxOffColor

The color to apply to a checkbox element when unchecked.

User

userNameTextColor

The text color of the user name element.

User

userNameFont

The font of the user name element.

Member state

mutedStateBackgroundColor

The Background color of muted members.

Member state

mutedStateIconColor

The tint color of the muted icon.

Member state

subInfoTextColor

The text color of members' state info.

Member state

subInfoFont

The text font of members' state info.

More menu

moreButtonColor

The color of the more menu button when activated.

More menu

moreButtonDisabledColor

The color of the more menu button when deactivated.


Moderate channels and members

Copy link

You can manage channels and members in the UIKit through the SBUModerationsViewController class. This class enables you to compose a management menu for operators, muted members, and banned members and change the freeze state of a channel.
The class also contains the moderation feature that can be used by a channel operator.

Note : By default, the channel moderation menu in the Channel settings view is activated for operators only.

How to use

Copy link

Configure the channel moderation tools through a simple implementation of the SBUModerationsViewController class.

SwiftObjective-C
// Case 1: Using channel url.
let moderationVC = SBUModerationsViewController(channelUrl: {CHANNEL_URL})
let naviVC = UINavigationController(rootViewController: moderationVC)
present(naviVC, animated: true)

// Case 2: Using channel object.
let moderationVC = SBUModerationsViewController(channel: {CHANNEL})
let naviVC = UINavigationController(rootViewController: moderationVC)
present(naviVC, animated: true)

Note : You can initialize the SBUModerationsViewController class by setting a ChannelUrl or SBDGroupChannel object.

Components and features

Copy link

The SBUModerationsViewController class is composed of items that are required to manage a channel and its members, such as freezing a channel or banning members.

Edit components

Copy link

The following table lists a set of customizable methods of the SBUModerationsViewController class.

List of methods

Copy link
MethodDescription

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

changeFreeze()

Access level: public
Changes freeze status on channel.

freezeChannel()

Access level: public
Freezes a channel.

unfreezeChannel()

Access level: public
Unfreezes the channel.

showOperatorList()

Access level: open
Shows an operator List.You can customize the SBUMemberListViewController class by overriding and implementing this method.

showMutedMemberList()

Access level: open
Shows the muted member list. You can customize the SBUMemberListViewController class by overriding and implementing this method.

showBannedMemberList()

Access level: open
Shows the banned member List. You can customize the SBUMemberListViewController class by overriding and implementing this method.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

ChannelSettings_Moderations

A text for Moderations.

ChannelSettings_Operators

A text for Operators.

ChannelSettings_Muted_Members

A text for Muted members.

ChannelSettings_Banned_Members

A text for Banned members.

ChannelSettings_Freeze_Channel

A text for Freeze channel.

Note : A set of common strings isn't included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons. The iconSet includes:

  • iconOperator, iconMuted, iconBanned, iconFreeze

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBUModerationsViewController class to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle

Note : We recommend you fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Set a custom theme

Copy link

You can customize the channelSettingsTheme through the SBUTheme.setChannelSetting(channelSettingsTheme:) method as below:

SwiftObjective-C
let settingsTheme = SBUChannelSettingsTheme(
    navigationBarTintColor: SBUColorSet.background100
    ...
)
SBUTheme.setChannelSettings(channelSettingsTheme: settingsTheme)

Note : You should call the setupStyle() method to update your user interface. Both the SBUModerationsViewController and SBUChannelSettingsViewController class use SBUTheme.channelSettingsTheme.

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the themes prior to viewController initialization. The following code shows how to customize the elements of the theme.

SwiftObjective-C
// Setting a theme.
SBUTheme.channelSettingsTheme.navigationBarTintColor = SBUColorSet.background100

Note : You should call the setupStyle() method to update your user interface.

- SBUChannelSettingsTheme

Copy link

The SBUChannelSettingsTheme object shares some of the properties contained in the SBUModerationsViewController.

CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button on the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button on the right side of the navigation bar.

Navigation bar

backgroundColor

The background color of the navigation bar.

Status bar

statusBarStyle

The style of the status bar.

Cell

cellTextFont

The text font of the cell.

Cell

cellTextColor

The text color of the cell.

Cell

cellSwitchColor

The color of the on-and-off toggle in the cell.

Cell

cellSeparateColor

The color of cell separators.

Cell

cellLeaveIconColor

The color of the leave icon in the cell.

Cell

cellSubTextFont

The sub text font of the cell.

Cell

cellSubTextColor

The sub text color of the cell.

Cell

cellTypeIconTintColor

The color of the type icon in the cell.

Cell

cellArrowIconTintColor

The color of the arrow icon in the cell.

User info view

userNameFont

The color of the user name element.

User info view

userNameTextColor

The text color of the user name element.

Action sheet

itemTextColor

The text color of the item.


Search messages

Copy link

In UIKit, you can search for messages within the SBUChannelViewController through the Search in Channel menu in the SBUChannelSettingsViewController. This will present a SBUMessageSearchViewController, which handles message search and displays the search results. Clicking on the result takes you to a new instance of SBUChannelViewController which features the message selected from the search results, with the keyword highlighted.

How to use

Copy link

You can create and present the SBUMessageSearchViewController as follows.

SwiftObjective-C
let searchVc = SBUMessageSearchViewController(channel: GROUP_CHANNEL)
self.present(UINavigationController(rootViewController: searchVc), animated: true, completion: nil)

Components

Copy link

The SBUMessageSearchViewController is composed of items that enable message search, such as a search bar and a list of search results.

Edit components

Copy link

The following table lists the customizable properties and methods of the SBUMessageSearchViewController class.

List of properties

Copy link
Property nameDescription

messageListParams

Type: SBDMessageListParams
A params object which can be passed into the enterChannel(with message:highlightInfo:messageListParams:) method when selecting a message from the search results.

customMessageSearchQueryBuilder

Type: (SBDMessageSearchQueryBuilder) -> Void
A query builder that is used when running the message search query. You can apply your custom query params by setting this builder, but the keyword, channelUrl and order parameters are set within the UIKit SDK.

List of methods

Copy link
MethodDescription

register(userCell:nib:)

Access level: public
Registers a new search result cell or edits an existing one. If the cell has Nib, the property adds Nib to the cell. If it doesn’t have one, it will not add Nib to the cell.

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the ViewController. You can customize the view by overriding and implementing this method.

search(keyword:)

Access level: public
Searches messages with the given keyword. You can customize the view by overriding and implementing this method.

onClickBack()

Access level: public
Called when the Cancel button is clicked. This dismisses the SBUMessageSearchViewController and goes back to the previous view.

enterChannel(with message:highlightInfo:messageListParams:)

Access level: public
Called when a message is selected from the message search results. When a message is selected, it moves to the SBUChannelViewController that shows a message list that starts from the selected message. The highlightInfo highlights the current searched keyword.

The SBUMessageSearchViewController class uses two of the SBUTheme, which are the SBUMessageSearchTheme and the SBUMessageSearchResultCellTheme. The SBUMessageSearchTheme is used for the elements of the SBUMessageSearchViewController while the SBUMessageSearchResultCellTheme is used for the SBUMessageSearchResultCell.

Theme properties cannot be accessed directly and should be customized only through the SBUTheme. Then you should call the setupStyle() afterwards in order to apply any changes you make through the SBUTheme.

- SBUMessageSearchTheme

Copy link

The SBUMessageSearchTheme object has properties used in the SBUMessageSearchViewController.

CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Status bar

statusBarStyle

The style of the status bar.

View

backgroundColor

The background color of the channel list view.

Search Field

searchTextColor

The text color of the search text field.

Search Field

searchTextFont

The font of the search text field.

Search Field

searchTextBackgroundColor

The background color of the search text field.

Search Field

searchPlaceholderColor

The text color of the search text field.

Search Field

searchIconTintColor

The tint color of the search icon.

Search Field

clearIconTintColor

The tint color of the clear icon.

Search Field

cancelButtonTintColor

The tint color of the cancel button.

- SBUMessageSearchResultCellTheme

Copy link

The SBUMessageSearchResultCellTheme object has properties used in the SBUMessageSearchResultCell.

CategoryPropertyDescription

View

backgroundColor

The background color of the cell.

View

separatorLineColor

The color of the separator line.

Title

titleFont

The font of the title element.

Title

titleTextColor

The text color of the title element.

Message

descriptionFont

The font of the message element.

Message

descriptionTextColor

The text color of the message element.

File Message

fileMessageFont

The font of the file name in the file message.

File Message

fileMessageTextColor

The text color of the file name in the file message.

File Message

fileMessageIconBackgroundColor

The background color of the file icon.

File Message

fileMessageIconTintColor

The tint color of the file icon.

Updated time

updatedAtFont

The font of the updated time.

Updated time

updatedAtTextColor

The text color of the updated time.


Configure channel settings

Copy link

In the UIKit, you can display and configure channels through the SBUChannelSettingsViewController class. In the class, you can edit the name and cover image of a channel, change notification status, check the number and list of members in the channel, and leave the specific channel. Also, the moderation menu will be activated if there is an operator in the channel.

Note : Simply setting your chat service to be based on either the channel list or channel can seamlessly lead users to the channel settings view.

How to use

Copy link

Configure channel settings without complicated implementation through the SBUChannelSettingsViewController class.

SwiftObjective-C
// Case 1: Using channel url.
let channelSettingsVC = SBUChannelSettingsViewController(channelUrl: {CHANNEL_URL})
let naviVC = UINavigationController(rootViewController: channelSettingsVC)
present(naviVC, animated: true)

// Case 2: Using channel object.
let channelSettingsVC = SBUChannelSettingsViewController(channel: {CHANNEL})
let naviVC = UINavigationController(rootViewController: channelSettingsVC)
present(naviVC, animated: true)

Note : You can initialize the SBUChannelSettingsViewController class by setting the ChannelUrl or SBDGroupChannel object.

Components and features

Copy link

The SBUChannelSettingsViewController is composed of channel configurations and channel information. The components and features of the SBUChannelSettingsViewController class include:

List of features

Copy link
FeatureDescription

Channel cover image

Displays the cover image of a channel.

Channel name

Displays the name of a channel.

Change channel cover image

Changes the cover image of a channel.

Change channel name

Changes the name of a channel.

Change notification status

Turns on or off the notifications of a channel.

Channel members

Displays a list of members in a channel and navigate to the member information view.

Channel update

Updates information of a channel.

Leave channel

Leaves a channel and return to a channel list.

Note : The screen shot on the left is the screen visible to general members while the one on the right is visible to operators.

Edit components

Copy link

The following table lists a set of customizable properties and methods of the SBUChannelSettingsViewController class.

List of properties

Copy link
Property nameTypeDescription

channelName

String

Edits the name of the channel.

List of methods

Copy link
MethodDescription

didReceiveError(_ message:)

(Deprecated. Use errorHandler(_ message:) instead.)
Access level: open
Receives an error message when an error occurs in the SBUChannelSettingsViewController. You can customize the view by overriding and implementing this method.

errorHandler(_ message:)

Access level: open
Receives an error message when an error occurs in the SBUChannelSettingsViewController. You can customize the view by overriding and implementing this method.

showMemberList()

Access level: open
Displays a list of members in a channel. You can customize the SBUMemberListViewController class by overriding and implementing this method.

showModerationList()

Access level: open
Displays a list of moderation tools. You can customize the SBUModerationsViewController class by overriding and implementing this method.

showSearch()

Access level: open
Displays a message search view controller. You can customize the SBUMessageSearchViewController class by overriding and implementing this method.

updateChannel(channelName:coverImage:)

Access level: public
Updates a channel name or cover image.

updateChannel(params:)

Access level: public
Updates a channel with channelParams.

changeNotification(isOn:)

Access level: public
Turns on a notification trigger option for the channel.

leaveChannel()

Access level: public
Leaves a channel and returns to the channel list.

selectChannelImage()

Access level: public
Displays an action sheet to select channel image.

changeChannelName()

Access level: public
Displays an alert to change a channel name.

Edit stringSet

Copy link

The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen. The stringSet includes:

List of properties

Copy link
Property nameDescription

ChannelSettings_Header_Title

The title of the ViewController.

ChannelSettings_Change_Name

A text for Change name.

ChannelSettings_Change_Image

A text for Change channel image.

ChannelSettings_Enter_New_Name

A text for Enter name.

ChannelSettings_Notifications

A text for Notifications status.

ChannelSettings_Members(count)

A text for (#) members.

ChannelSettings_Members_Title

A text for Members.

ChannelSettings_Leave

A text for Leave channel.

ChannelSettings_Moderations

A text for Moderations.

ChannelSettings_Operators

A text for Operators.

ChannelSettings_Muted_Members

A text for Muted members.

ChannelSettings_Banned_Members

A text for Banned members.

ChannelSettings_Freeze_Channel

A text for Freeze channel.

Note : A set of common icons is not included in the list. See the StringSet section in the Common resources menu.

Edit iconSet

Copy link

The SBUIConSet is a set of icons used to compose the screen. You need to modify the iconSet values in advance if you want to use different icons. The iconSet includes:

  • iconLeave, iconMembers, iconNotifications, iconShevronRight

Note : A set of common icons is not included in the list. See the IconSet section in the Common resources menu.

Customize the class

Copy link

You can subclass and customize the SBUChannelSettingsViewController to enhance the user experience of your app. The overridable methods include:

  • viewLifeCycle

Note : We recommend you should fully understand the usage of Sendbird Chat SDK for iOS when subclassing the class. Some actions may not work as expected depending on your customization.

Set a custom theme

Copy link

You can customize the channelSettingsTheme through the SBUTheme.setChannelSetting(channelSettingsTheme:) method as below:

SwiftObjective-C
let settingsTheme = SBUChannelSettingsTheme(
    navigationBarTintColor: SBUColorSet.background100
    ...

)

SBUTheme.setChannelSettings(channelSettingsTheme: settingsTheme)

Note : You should call the setupStyle() method to update your user interface.

Edit theme elements

Copy link

Themes can be customized through the SBUTheme. It is recommended to change the themes prior to the viewController initialization. The following code shows how to customize the elements of the theme.

SwiftObjective-C
// Setting a theme.
SBUTheme.channelSettingsTheme.navigationBarTintColor = SBUColorSet.background100

Note : You should call the setupStyle() method to update your user interface.

- SBUChannelSettingsTheme

Copy link

The SBUChannelSettingsTheme object has properties used in the SBUChannelSettingViewController.

CategoryPropertyDescription

Navigation bar

navigationBarTintColor

The tint color of the navigation bar.

Navigation bar

navigationBarShadowColor

The shadow color of the navigation bar.

Navigation bar

leftBarButtonTintColor

The tint color of the button at the left side of the navigation bar.

Navigation bar

rightBarButtonTintColor

The tint color of the button at the right side of the navigation bar.

Navigation bar

backgroundColor

The background color of the navigation bar.

Status bar

statusBarStyle

The style of the status bar.

Cell

cellTextFont

The text font of the cell.

Cell

cellTextColor

The text color of the cell.

Cell

cellSwitchColor

The color of the on-and-off toggle in the cell.

Cell

cellSeparateColor

The color of cell separators.

Cell

cellLeaveIconColor

The color of the leave icon in the cell.

Cell

cellSubTextFont

The sub text font of the cell.

Cell

cellSubTextColor

The sub text color of the cell.

Cell

cellTypeIconTintColor

The color of the type icon in the cell.

Cell

cellArrowIconTintColor

The color of the arrow icon in the cell.

User info view

userNameFont

The color of the user name element.

User info view

userNameTextColor

The text color of the user name element.

Action sheet

itemTextColor

The text color of the item.

Action sheet

itemColor

The color of the item.

Cell

cellNotificationIconColor

(Deprecated. Use cellTypeIconTintColor instead.)
The color of the notification icon in the cell.

Cell

cellMemberIconColor

(Deprecated. Use cellTypeIconTintColor instead.)
The color of the member icon in the cell.

Cell

cellMemberButtonColor

(Deprecated. Use cellArrowIconTintColor instead.)
The color of the member button in the cell.