Skip to content

Commit 420a406

Browse files
committed
🎉 Add support for iOS 13
1 parent ef19dbf commit 420a406

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ios/Classes/SwiftFlutterWebAuthPlugin.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public class SwiftFlutterWebAuthPlugin: NSObject, FlutterPlugin {
4141

4242
if #available(iOS 12, *) {
4343
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler)
44+
45+
if #available(iOS 13, *) {
46+
guard let provider = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController else {
47+
result(FlutterError(code: "FAILED", message: "Failed to aquire root FlutterViewController" , details: nil))
48+
return
49+
}
50+
51+
session.presentationContextProvider = provider
52+
}
53+
4454
session.start()
4555
keepMe = session
4656
} else {
@@ -53,3 +63,10 @@ public class SwiftFlutterWebAuthPlugin: NSObject, FlutterPlugin {
5363
}
5464
}
5565
}
66+
67+
@available(iOS 13, *)
68+
extension FlutterViewController: ASWebAuthenticationPresentationContextProviding {
69+
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
70+
return self.view.window!
71+
}
72+
}

0 commit comments

Comments
 (0)