Issue with UIKeyboardDidChangeFrameNotification: not receiving notification sometimes

Hello, I am developing a custom keyboard. Our team have been having trouble with the UIKeyboardDidChangeFrameNotification. I am looking for some help.

My keyboard extension changes its height when certain functions are triggered by the user. However, the hosting app do not always get the UIKeyboardDidChangeFrameNotification on keyboard height changes, which causes layout problems in the host.

My setup is: Xcode 12.5.1, iOS 14.2 on iPhone 12 mini. I debugged with a UITextField in a dummy application.

The problem can be reproduced with the following steps: Launch the keyboard in the dummy app.

  1. Toggle some function that changes the keyboard height. Here the UIKeyboardDidChangeFrameNotification is NOT received in the host sometimes.
  2. Return to home and re-open the host, where the keyboard resumes its normal height. Here the UIKeyboardDidChangeFrameNotification is NOT received in the host sometimes.

From my experience, this issue has been around for years and we still get complaints from our users every month.

If anyone has had the same issue, please leave a comment below :)