cationCenter.default let rects = noti fi cationCenter.noti fi cations(named: UIResponder.keyboardWillShowNoti fi cation ) .compactMap { noti fi cation -> CGRect? in let value = noti fi cation.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue return value?.cgRectValue } for await rect in rects { // Update the layout with keyboard rect print(rect ) } }