             defer { isFirstLayout = false }
 
             addKeyboardObservers()
-            messagesCollectionView.contentInset.bottom = keyboardOffsetFrame.height
-            messagesCollectionView.scrollIndicatorInsets.bottom = keyboardOffsetFrame.height
-            
+            messageCollectionViewBottomInset = keyboardOffsetFrame.height
             //Scroll to bottom at first load
             if scrollsToBottomOnFirstLayout {
                 messagesCollectionView.scrollToBottom(animated: false)

    
    /// A Boolean value used to determine if `viewDidLayoutSubviews()` has been called.
    private var isFirstLayout: Bool = true

    // MARK: - View Life Cycle



        if (keyboardEndFrame.origin.y + keyboardEndFrame.size.height) > UIScreen.main.bounds.height {
            // Hardware keyboard is found
            messageCollectionViewBottomInset = view.frame.size.height - keyboardEndFrame.origin.y - iPhoneXBottomInset
        } else {
            //Software keyboard is found
            let afterBottomInset = keyboardEndFrame.height > keyboardOffsetFrame.height ? (keyboardEndFrame.height - iPhoneXBottomInset) : keyboardOffsetFrame.height
            let differenceOfBottomInset = afterBottomInset - messageCollectionViewBottomInset
            let contentOffset = CGPoint(x: messagesCollectionView.contentOffset.x, y: messagesCollectionView.contentOffset.y + differenceOfBottomInset)
            
            messageCollectionViewBottomInset = afterBottomInset
            messagesCollectionView.setContentOffset(contentOffset, animated: true)
        }
        
    }
