         dataController.unreadSeparator = false
         dataController.dismissUnreadSeparator = false
         dataController.lastSeen = subscription?.lastSeen ?? Date()
+    }
+
+    // MARK: Handeling Keyboard
+
+    weak var keyboardHC: NSLayoutConstraint?
+    weak var textInputbarHC: NSLayoutConstraint?
+    weak var keyboardProxyView: UIView?
+    let textInputbarBackground = UIToolbar()
+
+    // Enables for the interactive keyboard dismissal.
+    // Gets called in scrollViewDidScroll and keyboardDidChangeFrame methods.
+    private func updateKeyboardConstraints() {
+        if keyboardHC == nil {
+            keyboardHC = self.view.constraints.first {
+                ($0.firstItem as? UIView) == self.view &&
+                    ($0.secondItem as? SLKTextInputbar) == self.textInputbar
+            }
+        }
+
+        // Adding textInputBar background so that the app can support devices with safe area insets.
+        // The tool bar (textInputBar) background sometimes dissapears on keyboard slide outs,
+        // with no real fix for it provided by Apple in UIKit.
+        updateTextInputbarBackground()
+
+        // keyboardProxyView is stored so as to account for an edge case on the iPad
+        // when it is split screen mode, where if a text field on the other app is
+        // active, then the textInputbar gets hidden under the keyboard.
+        if keyboardProxyView == nil {
+            keyboardProxyView = textInputbar.inputAccessoryView.superview
+        }
+
+        let keyboardWindowHeight = keyboardProxyView?.window?.frame.height ?? 0.0
+        let keyboardYOriginInWindow = keyboardProxyView?.frame.origin.y ?? 0.0
+
+        var keyboardHeight = keyboardWindowHeight - keyboardYOriginInWindow
+
+        if #available(iOS 11.0, *) {
+            keyboardHeight = keyboardHeight > view.safeAreaInsets.bottom ? keyboardHeight : view.safeAreaInsets.bottom
+        }
+
+        keyboardHC?.constant = keyboardHeight
+    }
+
+    private func updateTextInputbarBackground() {
+        if #available(iOS 11.0, *) {
+            if !textInputbar.subviews.contains(textInputbarBackground) {
+                insertTextInputbarBackground()
+            }
+
+            // Making the old background for textInputView, transparent
+            // after the safeAreaInsets are set. (Initially zero)
+            if view.safeAreaInsets.bottom > 0 {
+                textInputbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
+                textInputbar.backgroundColor = UIColor.clear
+            }
+
+            textInputbarHC?.constant = view.safeAreaInsets.bottom
+        }
+    }
+
+    private func insertTextInputbarBackground() {
+        if #available(iOS 11.0, *) {
+            textInputbar.insertSubview(textInputbarBackground, at: 0)
+            textInputbarBackground.translatesAutoresizingMaskIntoConstraints = false
+
+            textInputbarHC = textInputbarBackground.heightAnchor.constraint(equalTo: textInputbar.heightAnchor, multiplier: 1, constant: view.safeAreaInsets.bottom)
+            textInputbarHC?.isActive = true
+
+            textInputbarBackground.widthAnchor.constraint(equalTo: textInputbar.widthAnchor).isActive = true
+            textInputbarBackground.topAnchor.constraint(equalTo: textInputbar.topAnchor).isActive = true
+            textInputbarBackground.centerXAnchor.constraint(equalTo: textInputbar.centerXAnchor).isActive = true
+        }
+    }
+
+    @objc private func keyboardDidChangeFrame(_ notification: Notification) {
+        updateKeyboardConstraints()
     }
 
     // MARK: SlackTextViewController

    }

    deinit {
        NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
        SocketManager.removeConnectionHandler(token: socketHandlerToken)
        messagesToken?.invalidate()
        subscriptionToken?.invalidate()

        setupScrollToBottomButton()

        NotificationCenter.default.addObserver(self, selector: #selector(reconnect), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidChangeFrame(_:)), name: Notification.Name.UIKeyboardDidChangeFrame, object: nil)
        SocketManager.addConnectionHandler(token: socketHandlerToken, handler: self)

        if !SocketManager.isConnected() {
