     
     /// A Boolean value used to determine if `viewDidLayoutSubviews()` has been called.
     private var isFirstLayout: Bool = true
+    
+    private var messageCollectionViewBottomInset: CGFloat = 0 {
+        didSet {
+            messagesCollectionView.contentInset.bottom = messageCollectionViewBottomInset
+            messagesCollectionView.scrollIndicatorInsets.bottom = messageCollectionViewBottomInset
+        }
+    }
 
     // MARK: - View Life Cycle
 


        if (keyboardEndFrame.origin.y + keyboardEndFrame.size.height) > UIScreen.main.bounds.height {
            // Hardware keyboard is found
            let bottomInset = view.frame.size.height - keyboardEndFrame.origin.y - iPhoneXBottomInset
            messagesCollectionView.contentInset.bottom = bottomInset
            messagesCollectionView.scrollIndicatorInsets.bottom = bottomInset

        } else {
            //Software keyboard is found
            let bottomInset = keyboardEndFrame.height > keyboardOffsetFrame.height ? (keyboardEndFrame.height - iPhoneXBottomInset) : keyboardOffsetFrame.height
            messagesCollectionView.contentInset.bottom = bottomInset
            messagesCollectionView.scrollIndicatorInsets.bottom = bottomInset
            messagesCollectionView.scrollToBottom(animated: true)
        }
        
    }

            defer { isFirstLayout = false }

            addKeyboardObservers()
            messageCollectionViewBottomInset = keyboardOffsetFrame.height
            //Scroll to bottom at first load
            if scrollsToBottomOnFirstLayout {
                messagesCollectionView.scrollToBottom(animated: false)
