Skip to content

Commit db117d8

Browse files
authored
Fixed: KeyWindow was deprecated in iOS 13.
1 parent ddb47bd commit db117d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

MailDemo/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension ContentView {
5959
guard MFMailComposeViewController.canSendMail() else {
6060
return
6161
}
62-
let vc = UIApplication.shared.keyWindow?.rootViewController
62+
let vc = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
6363

6464
let composeVC = MFMailComposeViewController()
6565
composeVC.mailComposeDelegate = mailComposeDelegate
@@ -87,7 +87,7 @@ extension ContentView {
8787
guard MFMessageComposeViewController.canSendText() else {
8888
return
8989
}
90-
let vc = UIApplication.shared.keyWindow?.rootViewController
90+
let vc = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
9191

9292
let composeVC = MFMessageComposeViewController()
9393
composeVC.messageComposeDelegate = messageComposeDelegate

0 commit comments

Comments
 (0)