View controller gets dismissed when creating a new chat

[Problem/Question]
The issue we are having is when we show a channel list view controller. When the user hits the new chat button, it works properly with the navigation, but when they hit the create button with the recipient selected, it dismisses the view controller showing the channel list view controller from Sendbird UIkit. This create an issue where it takes users to the initial screen in our app. The intended behavior for the SDK is too just show that new channel and not dismiss the presenting view controller of the controller the navigation controller showing the channel list.


// If problem, please fill out the below. If question, please delete.
[UIKit Version]

// What version of the SDK are you using?
V4 across the board

[Reproduction Steps]
// Please provide reproduction steps and, if possible, code snippets.
[Frequency]

Every time

[Current impact]
I can not use my app after messaging someone for the first time. Navigation is completely broken

Hi @Ryan_Anderson - welcome to the Sendbird community!

Please refer to the UIKit sample here to check if anything is off with your implementation. You can also try running the sample to check the expected behavior.

If it doesn’t help, please share the code snippets from your implementation, and explain any customizations that you are trying to do.

Here is the code where I show the view controller:

class ChatsVC: SBUGroupChannelListViewController {

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    DispatchQueue.main.async {
        self.navigationItem.hidesBackButton = true
        self.navigationItem.leftBarButtonItem = nil
        self.navigationController?.navigationBar.layoutIfNeeded()
    }
}

}

this is shown in a UITabBarViewController as a tab.

the SBUGroupChannelListViewController is the view controller used to show the list of channels, pretty much our “Chat” tab

Thanks for the details. I’m assuming that the issue is only with the UI; the channel is getting created, and you are able to confirm it either from the Dashboard or the channel can be seen when you go back to the channel list in the app.

The channel is created from SBUCreateChannelViewController. To debug it further, I will suggest setting a breakpoint as shown in the screenshot – reference source code here.

It should stop at this line when you click on the Create channel button, and then you can trace it from there to see what’s happening with the UI after the channel is created. OR if it doesn’t stop at the breakpoint, then it means something is preventing it (either something with the tech stack or some customization).

Thanks for your response. It seems the code was locked in the library and could not be modified like how you show it in the demo project. Unable to set breakpoints in the locked file.

We are showing this controller in a ui navigation controller inside a tab bar controller and having this behavior. Would be great if we can clarify why this is happening and also on how to address it so creating a new channel conversation does not result in this unexpected behavior where the entire tab bar view controller is getting dismissed.

There are two components - SBUGroupChannelListViewController to render the list of channels, and SBUCreateChannelViewController to create a new channel. The code snippet that you have shared is for the former. However, the issue that you are facing is for the latter. Due to this, we are lacking information to investigate it.

When you say tabs, I’m assuming you have a UI similar to the sample app that I had linked earlier (screenshot below). Can you please share a recording showing your source code and the issue?

In the meantime, to be able to debug it further the way I suggested earlier, you will have to integrate the UIKit using source code instead of the precompiled library. Since the UIKit is open source, you’ll be able to debug the code more effectively to identify and fix the issue you’re facing.

Our chats vc code is here

class ChatsVC: SBUGroupChannelListViewController {

 override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    DispatchQueue.main.async {
        self.navigationItem.hidesBackButton = true
        self.navigationItem.leftBarButtonItem = nil
        self.navigationController?.navigationBar.layoutIfNeeded()
    }
  }
}

…and is a tab on a UITabBarController. You can see in the screen capture when the new channel is created is dismisses the tab bar controller showing the channel list view controller, or ChatsVC, so there is no way I can control it past that point.

It wont let me upload the video attachment because it says I am a new user.

here is a vimeo link for the screen recording:

Thank you, the recording is super helpful in understanding the behavior you are experiencing. I have reached out to the UIKit engineers to understand what could be causing it. I will update you as soon as I hear back.
Appreciate your patience!

Sounds good, thank you!

Engineers have confirmed that it’s happening due to the custom tabbar. They are going to provide a customization guide for it. I will let you know when it’s ready.

Is there any way we can hop on a quick zoom call

I’m starting a DM with you.

Here is the solution to the issue shown in the video.

The rootViewController is not a separate property, but rather the top-level viewController.
Both UINavigationController and UITabbarController can be used as rootViewControllers because they are subclasses of UIViewController .

  1. Create the CustomCreatedChannelViewController class.
class CustomCreatedChannelViewController: SBUCreateChannelViewController {
    override func createChannelViewModel(
        _ viewModel: SBUCreateChannelViewModel,
        didCreateChannel channel: BaseChannel?,
        withMessageListParams messageListParams: MessageListParams?
    ) {
        SendbirdUI.moveToChannel(
            channelURL: channelURL,
            messageListParams: messageListParams,
            rootViewController: self.parent
        )
    }
}
  1. Before using a customized viewController class, please set it in the SBUViewControllerSet.
    SBUViewControllerSet.CreateChannelViewController = CustomCreatedChannelViewController.self
1 Like