livechat / chat-window-ios

Embeding LiveChat mobile chat window in iOS application
MIT License
24 stars 31 forks source link

Integration with SwiftUI app #52

Closed kneekey23 closed 4 years ago

kneekey23 commented 4 years ago

is this possible? Right now I pulled in the files into my SwiftUIapp and I made the LiveChatOverlayController conform to UIViewControllerRepresentable and I also set the LiveChat.windowScene in my Scene Delegate. The view actually loads but it's indefinitely on the spinning loading view. Any way to get this to work?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

        // Create the SwiftUI view that provides the window contents.
        let mainView = MainView()
        let loginView = LoginView()

        // Use a UIHostingController as window root view controller.
        if let windowScene = scene as? UIWindowScene {
            LiveChat.windowScene = windowScene
            let window = UIWindow(windowScene: windowScene)
            if UserDefaults.standard.string(forKey: "eventId") != nil {
            window.rootViewController = UIHostingController(rootView: mainView)
            }
            else {
                window.rootViewController = UIHostingController(rootView: loginView)
            }
            self.window = window

            window.makeKeyAndVisible()
        }
    }
extension LiveChatOverlayViewController: UIViewControllerRepresentable {
    public typealias UIViewControllerType = LiveChatOverlayViewController

    public func makeUIViewController(context: UIViewControllerRepresentableContext<LiveChatOverlayViewController>) -> LiveChatOverlayViewController {
        return LiveChatOverlayViewController()
    }

    public func updateUIViewController(_ uiViewController: LiveChatOverlayViewController, context: UIViewControllerRepresentableContext<LiveChatOverlayViewController>) {
        //
    }

}

Simulator Screen Shot - iPhone 11 Pro - 2020-01-01 at 20 23 30

kneekey23 commented 4 years ago

issue was caused by missing license id. fixed.