Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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