zendesk / react-native-sunshine-conversations

React Native wrapper for Smooch.io
MIT License
36 stars 26 forks source link

Chatview inside a tabbar #8

Closed Thymo closed 8 years ago

Thymo commented 8 years ago

Hi,

I'm trying to add Smooch inside a react-native component so a user can open Smooch through a tabbar menu instead of the default popup / modal screen.

I created an RCTViewManager class (based on https://facebook.github.io/react-native/docs/native-components-ios.html) that uses [Smooch newConversationViewController].view as its UIView.

The problem is that all chat messages are hidden. Just the camera icon and send button are visible, although they do not work.

Any ideas how I can get this to work?

mspensieri commented 8 years ago

Hi @Thymo,

From what I know about React Native, and from a cursory scan of the doc you linked, I'm pretty sure Smooch isn't able to work in this way (i.e. embedded in a tab bar controller) in a react-native app. The reason is simple: there are no UIViewController lifecycle hooks.

The doc you linked is specifically tailored to adding pre-built UIView objects, not UIViewController views. Our conversation controller is strongly coupled to the UIViewController lifecycle methods (e.g. viewWillAppear, viewDidDisappear`, etc...). Without those lifecycle methods being called at the correct time, the conversation view controller will not render or handle user interaction correctly.

If there's a way to render a native UITabBarController in a react-native application, then you should be able to add Smooch correctly as a child of that controller. If that's not possible, I don't think you'll be able to accomplish what you're trying to do unfortunately.