Chat UIKit Android v3
Chat UIKit Android
Chat UIKit
Version 3

Customize UIKitFragmentFactory

Copy link

UIKitFragmentFactory is a class that provides and manages all fragments used in Sendbird UIKit. While an activity creates the basic UI screen and allows the user to navigate between different screens, the fragment within the activity is what allows you to customize components and manage data. The UIKitFragmentFactory class creates the fragment used in each activity.

If you wish to customize a fragment, you need to inherit the UIKitFragmentFactory class and override the method that creates the fragment. Then, you must return the customized fragment in order to apply the customization throughout the UIKit. Before creating the fragment, you need to also send data from the activity to the customized fragment through the Bundle class. The fragment will then use the data to build a view.

Note: If you're only using fragments to build a screen in UIKit instead of using an activity, you can skip the following steps.

  1. You need to first override the methods of the fragment you wish to customize by inheriting the UIKitFragmentFactory class. Refer to the code below as an example.
class CustomFragmentFactory : UIKitFragmentFactory() {

    // TODO : Override the methods that create the fragment you wish to customize.

    override fun newChannelFragment(channelUrl: String, args: Bundle): Fragment {
        // TODO : Return the customized `ChannelFragment` here.
        // You can send data from activity to the custom fragment through `Bundle`.
        val fragment = CustomChannelFragment()
        return ChannelFragment.Builder(channelUrl)
  1. Apply the customized UIKitFragmentFactory to Application using SendbirdUIKit.setUIKitFragmentFactory(UIKitFragmentFactory).
class MyApplication : Application() {
    override fun onCreate() {