SBUBaseChannelViewController

@objcMembers
open class SBUBaseChannelViewController : SBUBaseViewController, SBUBaseChannelViewModelDelegate, SBUBaseChannelModuleHeaderDelegate, SBUBaseChannelModuleListDelegate, SBUBaseChannelModuleListDataSource, SBUBaseChannelModuleInputDelegate, SBUBaseChannelModuleInputDataSource, SBUBaseChannelViewModelDataSource, UIGestureRecognizerDelegate, UIViewControllerTransitioningDelegate, PHPickerViewControllerDelegate, UIImagePickerControllerDelegate, UIDocumentPickerDelegate, UIDocumentInteractionControllerDelegate, SBUSelectablePhotoViewDelegate, SBUFileViewerDelegate, SBUCommonViewModelDelegate

Undocumented

UI Properties (Public)

Logic Properties (Public)

Lifecycle

  • Initiates view controller to enter a channel with its URL, message list params and a specific timestamp representing a starting potint.

    See the example below for params generation.

        let params = SBDMessageListParams()
        params.includeMetaArray = true
        params.includeReactions = true
        params.includeThreadInfo = true
        ...
    

    Note

    The reverse and the previousResultSize properties in the SBDMessageListParams are set in the UIKit. Even though you set that property it will be ignored.

    Since

    2.1.0

    Declaration

    Swift

    required public init(
        channelUrl: String,
        startingPoint: Int64 = .max,
        messageListParams: SBDMessageListParams? = nil
    )

    Parameters

    channelUrl

    Channel’s URL

    startingPoint

    A starting point timestamp to start the message list from. The default value is Int64.max

    messageListParams

    SBDMessageListParams object to be used when loading messages.

  • Undocumented

    Declaration

    Swift

    open override func loadView()
  • Undocumented

    Declaration

    Swift

    open override func viewWillAppear(_ animated: Bool)
  • Undocumented

    Declaration

    Swift

    open override func viewDidLoad()
  • Undocumented

    Declaration

    Swift

    open override func viewWillDisappear(_ animated: Bool)
  • Undocumented

    Declaration

    Swift

    open override var preferredStatusBarStyle: UIStatusBarStyle { get }

ViewModel

  • Creates the view model, loading initial messages from given starting point.

    Note

    If you want to customize the viewModel, override this function

    Since

    3.0.0

    Declaration

    Swift

    open func createViewModel(
        channel: SBDBaseChannel? = nil,
        channelUrl: String? = nil,
        messageListParams: SBDMessageListParams? = nil,
        startingPoint: Int64? = Int64.max,
        showIndicator: Bool = true
    )

    Parameters

    startingPoint

    The starting point timestamp of the messages. nil to start from the latest.

    showIndicator

    Whether to show loading indicator on loading the initial messages.

Sendbird UIKit Life cycle

  • Sets up views including module components.

    Important

    When you override this method, please call super.setupViews after configure method of the component. e.g.

    override func setupViews() {
    self.baseHeaderComponent = SBUModuleSet.groupChannelModule.headerComponent()
    self.baseHeaderComponent?.configure(delegate: self, theme: self.theme)
    
    super.setupViews()
    }
    

    Declaration

    Swift

    open override func setupViews()
  • Declaration

    Swift

    open override func setupStyles()
  • Setups scrollBottom view style.

    Declaration

    Swift

    public func setupScrollBottomViewStyle(
        scrollBottomView: UIView,
        theme: SBUComponentTheme = SBUTheme.componentTheme
    )

    Parameters

    scrollBottomView

    Scroll bottom view

    theme

    theme for setup

Channel

  • Updates channelTitle with channel and channelName

    Since

    3.0.0

    Declaration

    Swift

    public func updateChannelTitle()

*

  • Updates channelStatus with channel

    Since

    3.0.0

    Declaration

    Swift

    public func updateChannelStatus()

Message: Menu

  • This function shows cell’s menu.

    This is used when the reaction feature is activated. This function configures the menu items using the message object.

    Since

    3.0.0

    Declaration

    Swift

    public func showMenuViewController(_ cell: UITableViewCell, message: SBDBaseMessage)

    Parameters

    cell

    Message cell

    message

    Message object

  • This function shows cell’s menu. This is used when the reaction feature is activated.

    Since

    1.2.5

    Declaration

    Swift

    public func showMenuViewController(
        _ cell: UITableViewCell,
        message: SBDBaseMessage,
        types: [MessageMenuItem]?
    )

    Parameters

    cell

    Message cell

    message

    Message object

    types

    Type array of menu items to use

  • This function shows cell’s menu.

    This is used when the reaction feature is inactivated. This function configures the menu items using the message object.

    Since

    3.0.0

    Declaration

    Swift

    public func showMenuModal(
        _ cell: UITableViewCell,
        indexPath: IndexPath,
        message: SBDBaseMessage
    )

    Parameters

    cell

    Message cell

    indexPath

    IndexPath

    message

    Message object

  • This function shows cell’s menu. This is used when the reaction feature is inactivated.

    Since

    1.2.5

    Declaration

    Swift

    public func showMenuModal(
        _ cell: UITableViewCell,
        indexPath: IndexPath,
        message: SBDBaseMessage,
        types: [MessageMenuItem]?
    )

    Parameters

    cell

    Message cell

    indexPath

    IndexPath

    message

    Message object

    types

    Type array of menu items to use

  • This function shows cell’s menu: retry, delete, cancel.

    This is used when selected failed message.

    Since

    2.1.12

    Declaration

    Swift

    public func showFailedMessageMenu(message: SBDBaseMessage)

    Parameters

    message

    Message object

  • This function shows delete message alert.

    Since

    3.0.0

    Declaration

    Swift

    public func showDeleteMessageMenu(message: SBDBaseMessage,
                                      oneTimetheme: SBUComponentTheme? = nil)

    Parameters

    message

    message object to delete

    oneTimetheme

    One-time theme

  • Shows channel settings view controller such as SBUChannelSettingsViewController

    Declaration

    Swift

    open func showChannelSettings()
  • This function presents SBUEmojiListViewController

    Since

    1.1.0

    Declaration

    Swift

    open func showEmojiListModal(message: SBDBaseMessage)

    Parameters

    message

    SBDBaseMessage object

  • This function creates message menu items with cell and message.

    Declaration

    Swift

    public func createMessageMenuTypes(_ cell: UITableViewCell,
                                       message: SBDBaseMessage) -> [MessageMenuItem]?

    Parameters

    cell

    Sendbird’s messageCell object

    message

    SBDBaseMessage object

    Return Value

    message menu type array

New message info

  • This function updates new message info view’s hidden status.

    Since

    3.0.0

    Declaration

    Swift

    public func updateNewMessageInfo(hidden: Bool)

    Parameters

    hidden

    hidden status

Common

  • This function opens a file according to the file type.

    Since

    3.0.0

    Declaration

    Swift

    open func openFile(fileMessage: SBDFileMessage)

    Parameters

    fileMessage

    fileMessage object

  • This function increases the new message count.

    Declaration

    Swift

    @discardableResult
    public func increaseNewMessageCount() -> Bool

MessageInputView

Error handling

  • If an error occurs in viewController, a message is sent through here. If necessary, override to handle errors.

    Declaration

    Swift

    open override func errorHandler(_ message: String?, _ code: NSInteger? = nil)

    Parameters

    message

    error message

    code

    error code

SBUBaseChannelViewModelDelegate

SBUBaseChannelModuleHeaderDelegate

SBUBaseChannelModuleListDelegate

SBUBaseChannelModuleListDataSource

SBUBaseChannelModuleInputDelegate

SBUBaseChannelViewModelDataSource

UIGestureRecognizerDelegate

UIViewControllerTransitioningDelegate

UIImagePickerControllerDelegate

PHPickerViewControllerDelegate

  • Override this method to handle the results from PHPickerViewController. As defaults, it doesn’t support multi-selection and live photo.

    Important

    To use this method, please assign self as delegate to PHPickerViewController object.

    Declaration

    Swift

    @available(iOS 14, *)
    open func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult])

UIDocumentPickerDelegate

UIDocumentInteractionControllerDelegate

SBUSelectablePhotoViewDelegate

SBUFileViewerDelegate

SBUCommonViewModelDelegate

(Deprecated) UI Properties

  • Undocumented

    Declaration

    Swift

    public var titleView: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public var leftBarButton: UIBarButtonItem? { get set }
  • Undocumented

    Declaration

    Swift

    public var rightBarButton: UIBarButtonItem? { get set }
  • Undocumented

    Declaration

    Swift

    public var messageInputView: SBUMessageInputView? { get set }
  • Undocumented

    Declaration

    Swift

    public var tableView: UITableView { get set }
  • Undocumented

    Declaration

    Swift

    public var channelStateBanner: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public var emptyView: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public var newMessageInfoView: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public var scrollBottomView: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public var userProfileView: UIView? { get set }
  • Undocumented

    Declaration

    Swift

    public func reloadTableView()
  • Undocumented

    Declaration

    Swift

    public func setEditMode(for userMessage: SBDUserMessage?)

Input mode

  • This is used to messageInputView state update.

    Declaration

    Swift

    @available(*, deprecated, renamed: "inputComponent.updateMessageInputModeState(﹚", message: "This function has been moved to `SBDBaseChannelModule.List`.")
    public func updateMessageInputModeState()
  • Undocumented

    Declaration

    Swift

    @objc
    public var channel: SBDBaseChannel? { get }
  • Undocumented

    Declaration

    Swift

    public var channelUrl: String? { get }
  • Undocumented

    Declaration

    Swift

    public var startingPoint: Int64? { get }
  • Undocumented

    Declaration

    Swift

    public var inEditingMessage: SBDUserMessage? { get }
  • Undocumented

    Declaration

    Swift

    public var messageListParams: SBDMessageListParams { get }
  • Undocumented

    Declaration

    Swift

    public var customizedMessageListParams: SBDMessageListParams? { get }
  • Undocumented

    Declaration

    Swift

    public var messageList: [SBDBaseMessage] { get }
  • Undocumented

    Declaration

    Swift

    public var fullMessageList: [SBDBaseMessage] { get }

Channel

  • This function is used to load channel information.

    Declaration

    Swift

    @available(*, deprecated, renamed: "viewModel.loadChannel(channelUrl:messageListParams:﹚", message: "This function has been moved to `SBUBaseChannelViewModel`.")
    public func loadChannel(channelUrl: String, messageListParams: SBDMessageListParams? = nil)

    Parameters

    channelUrl

    channel url

    messageListParams

    (Optional) The parameter to be used when getting channel information.

  • This function clears current message lists

    Since

    2.1.0

    Declaration

    Swift

    @available(*, deprecated, renamed: "viewModel.clearMessageList(﹚", message: "This function has been moved to `SBUBaseChannelViewModel`.")
    public func clearMessageList()
  • Undocumented

    Declaration

    Swift

    public func setReaction(message: SBDBaseMessage, emojiKey: String, didSelect: Bool)

List

Sending messages

Common

Scroll

  • Undocumented

    Declaration

    Swift

    public func setScrollBottomView(hidden: Bool?)
  • This function scrolls to bottom.

    Declaration

    Swift

    @available(*, deprecated, renamed: "baseChannelModuleDidTapScrollToButton(_:animated:﹚", message: "This function has been moved to `SBUBaseChannelModuleListDelegate`.")
    public func scrollToBottom(animated: Bool)

    Parameters

    animated

    Animated

Keyboard

  • This function registers keyboard notifications.

    Since

    3.0.0

    Declaration

    Swift

    public func registerKeyboardNotifications()

*

  • This functions adds the hide keyboard gesture in tableView.

    Since

    1.2.5

    Declaration

    Swift

    public func addGestureHideKeyboard()
  • This function changes the messageInputView bottom constraint using keyboard height.

    Since

    1.2.5

    Declaration

    Swift

    @objc
    public func keyboardWillShow(_ notification: Notification)

    Parameters

    notification

    Notification object with keyboardFrame information

  • This function changes the messageInputView bottom constraint using keyboard height.

    Since

    1.2.5

    Declaration

    Swift

    @objc
    public func keyboardWillHide(_ notification: Notification)

    Parameters

    notification

    Notification object with keyboardFrame information

  • This function dismisses the keyboard.

    Since

    1.2.5

    Declaration

    Swift

    @objc
    public func dismissKeyboard()