Customizing the User Interface

Override a view controller

To override a view controller you need to do the following:

  1. Create a subclass of the class you want to override. For example, if you wanted to override the BLoginViewController you would make a subclass:

    public class CustomLoginViewController: BLoginViewController
  2. Register your subclass with the Chat SDK. After you have initialized the Chat SDK in your app delegate, add the following:

    BChatSDK.ui()?.setLoginViewController(CustomLoginViewController)
  3. Now the Chat SDK will load your view controller rather than the standard one.

Overriding using a provider

In some cases, it's necessary for the view controller to be given a parameter when it's created. An example of this is with the chat view controller which needs to be given the thread to load. In this case, rather than registering the view controller directly, we register a provider.

  1. Create a subclass of the class you want to override. For example, if you wanted to override the BChatViewController you would make a subclass:

    public class CustomChatViewController: BChatViewController
  2. Register your provider with the Chat SDK. After you have initialized the Chat SDK in your app delegate, add the following:

     BChatSDK.ui()?.setChatViewController({ (thread: PThread?) -> BChatViewController? in
         return CustomChatViewController.init(thread: thread)
     })
  3. Now the Chat SDK will load your view controller rather than the standard one.

Last updated