Skip to content

Commit

Permalink
SceneDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
Will5 committed Sep 9, 2024
1 parent 67a3cc1 commit a331b9a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions flutter_web_auth_2/ios/Classes/SwiftFlutterWebAuth2Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,25 @@ public class SwiftFlutterWebAuth2Plugin: NSObject, FlutterPlugin {
if #available(iOS 13, *) {
var rootViewController: UIViewController? = nil

// Try to get root view controller from the scene delegate if available
if rootViewController == nil {
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
rootViewController = scene.windows.first?.rootViewController
}
}

// FlutterViewController
if (rootViewController == nil) {
if rootViewController == nil {
rootViewController = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController
}

// UIViewController
if (rootViewController == nil) {
if rootViewController == nil {
rootViewController = UIApplication.shared.keyWindow?.rootViewController
}

// ACQUIRE_ROOT_VIEW_CONTROLLER_FAILED
if (rootViewController == nil) {
if rootViewController == nil {
result(FlutterError.acquireRootViewControllerFailed)
return
}
Expand Down

0 comments on commit a331b9a

Please sign in to comment.