Present an mail compose view controller modally in UIKit environment
private func presentMailCompose() {
guard MFMailComposeViewController.canSendMail() else {
return
}
// The following windows is the problem !!! It deprecated in iOS 15.0
let vc = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = mailComposeDelegate
// Customize here
vc?.present(composeVC, animated: true)
}