         window.rootViewController = viewController
         return window
     }
-}
+
+    @available(iOS 13.0, *)
+    private func getFirstForegroundScene() -> UIWindowScene? {
+        let connectedScenes = UIApplication.shared.connectedScenes
+        if let windowActiveScene = connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
+            return windowActiveScene
+        } else {
+            return connectedScenes.first(where: { $0.activationState == .foregroundInactive }) as? UIWindowScene
+        }
+    }
+}

        // If the alertType is .none, an alert will not be presented.
        // If the `updaterWindow` is not hidden, then an alert is already presented.
        // The latter prevents `UIAlertController`'s from appearing on top of each other.
        if rules.alertType != .none, updaterWindow.isHidden {
            alertController?.show(window: updaterWindow)
        } else {
            // This is a safety precaution to avoid multiple windows from presenting on top of each other.

// MARK: - Helpers

private extension PresentationManager {
    private func createWindow() -> UIWindow? {
        var window = UIWindow()
        if #available(iOS 13.0, *) {
            guard let windowScene = getFirstForegroundScene() else { return nil }
            window = UIWindow(windowScene: windowScene)
        } else {
            window = UIWindow(frame: UIScreen.main.bounds)
