0

I have a container ViewController that acts as a tabController. The container basically handles all of the segue and the viewcontrollers that'll be shown. I need to show the smooch UI within the container viewcontroller. Would any of you know how to do this? The documentation just shows the Smooch UI coming up as a popover or as a segue.

To be more clear, the white space which is a UIView is where I need the Smooch UI to show up. Any help is appreciated!

EDIT: Here's what it looks like after code is implemented enter image description here

1 Answer 1

1

You can use the +newConversationViewController method to obtain an instance of the Smooch conversation view, and then display it as a child of your tab bar controller

UITabBarController* tabBar = [[UITabBarController alloc] init];    
UIViewController* convoVC = [Smooch newConversationViewController];

[tabBar addChildViewController:convoVC];

Edit

To add Smooch as a child of a regular UIViewController, you can use the following code

UIViewController* vc = [[UIViewController alloc] init];

UIViewController* convoVC = [Smooch newConversationViewController];
[vc addChildViewController:convoVC];
[vc.view addSubview:convoVC.view];

You'll have to manage presentation of the view controller yourself though, because I believe the view won't have a Done button when presented in this way. And if your bottom bar isn't a true tab bar, then the chat input will likely appear beneath or on top of it since the input docks to the bottom of the screen

5
  • Only problem is that the container is subclassing a UIViewController rather than a UITabBarController (don't ask me why) so not sure if this helps
    – John D
    Dec 15, 2016 at 18:35
  • Edited my answer to show how to add it to a regular UIViewController. I'm not convinced it'll display correctly though. Can you explain a bit more about your view hierarchy and why you are using a pseudo UITabBarController ?
    – mspensieri
    Dec 15, 2016 at 20:08
  • I don't really have a reason why I'm using a pseudo UITabBarController. Someone else did it and it's way too painful to rip it out. Basically the Container ViewController has a NavBar and Bottom Tab Bar. Any View shown in the middle is just a viewcontroller initialized then the bar shows the viewcontroller's view. Also see Edit as to how it showed up when I implemented
    – John D
    Dec 16, 2016 at 15:05
  • That's what I meant by "if your bottom bar isn't a true tab bar, then the chat input will likely appear beneath or on top of it". There isn't really a way to fix this unfortunately. You'll probably either need to hide your bottom bar, or present the Smooch view controller in a more traditional way
    – mspensieri
    Dec 19, 2016 at 18:18
  • Yeah I realized. Thanks for all the help. I'll probably try to show the smooch UI in a different way instead!
    – John D
    Dec 19, 2016 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.