New typed notifications for keyboards do not work?

@MainActor
class KeyboardObserver {
    var token: NotificationCenter.ObservationToken!

    func registerObserver(screen: UIScreen) {
        let center = NotificationCenter.default
        token = center.addObserver(of: screen, for: .keyboardWillShow) { keyboardState in
            print("+++ Keyboard showed up!")
        }
    }
}

The notification is never called.

The sample code from the sessions also does not work for me.

let keyboardObserver = NotificationCenter.default.addObserver(
        of: UIScreen.self
        for: .keyboardWillShow
    ) { message in
        UIView.animate(
            withDuration: message.animationDuration, delay: 0, options: .flushUpdates
        ) {
            // Use message.endFrame to animate the layout of views with the keyboard
            let keyboardOverlap = view.bounds.maxY - message.endFrame.minY
            bottomConstraint.constant = keyboardOverlap
        }
    }
@MainActor
class KeyboardObserver {
  func registerObserver(screen: UIScreen) {
    let center = NotificationCenter.default
    let token = center.addObserver(
      of: screen,
      for: .keyboardWillShow
    ) { keyboardState in
      let startFrame = keyboardState.startFrame
      let endFrame = keyboardState.endFrame

      self.keyboardWillShow(startFrame: startFrame, endFrame: endFrame) 
    }
  }
  
  func keyboardWillShow(startFrame: CGRect, endFrame: CGRect) {}
}

This is still not working in beta 7. Am I holding the API wrong?

Did you file a feedback report yet? If not, I’d suggest that you file one and share the report ID here. Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Yes, I did so a while back. FB19519914

I just updated the sample project with a strong reference to the observer, but that still does not work, but there's a console log now:

Unable to deliver Notification to Message observer because KeyboardWillShowMessage.makeMessage() returned nil. If this is unexpected, check or provide an implementation of makeMessage() which returns a non-nil value for this notification's payload.

New typed notifications for keyboards do not work?
 
 
Q