Skip to content

Commit

Permalink
fix: make getTopWindow more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
thespacemanatee committed Oct 8, 2024
1 parent 0553cd8 commit d141c25
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ios/extensions/UIWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ public extension UIWindow {

func getTopWindow() -> UIWindow? {
// Return the keyboard window if it's available, otherwise return the last window
return keyboardWindow ?? UIApplication.shared.windows.last
if let keyboardWindow = keyboardWindow {
return keyboardWindow
}

if #available(iOS 13.0, *) {
let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene
return windowScene?.windows.last { $0.isKeyWindow }
} else {
return UIApplication.shared.windows.last { $0.isKeyWindow }
}
}
}

Expand Down

0 comments on commit d141c25

Please sign in to comment.