Skip to content

Commit 67e1e9e

Browse files
committed
Enable partial ASWebAuthenticationSession.Callback support
Related: #104
1 parent c7c0c19 commit 67e1e9e

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

flutter_web_auth_2/ios/Classes/SwiftFlutterWebAuth2Plugin.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ public class SwiftFlutterWebAuth2Plugin: NSObject, FlutterPlugin {
6262
}
6363

6464
if #available(iOS 12, *) {
65-
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler!)
65+
var _session: ASWebAuthenticationSession? = nil
66+
if #available(iOS 17.4, *) {
67+
_session = ASWebAuthenticationSession(url: url, callback: ASWebAuthenticationSession.Callback.customScheme(callbackURLScheme), completionHandler: completionHandler!)
68+
} else {
69+
_session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler!)
70+
}
71+
let session = _session!
6672

6773
if #available(iOS 13, *) {
6874
var rootViewController: UIViewController? = nil

flutter_web_auth_2/macos/Classes/FlutterWebAuth2Plugin.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ public class FlutterWebAuth2Plugin: NSObject, FlutterPlugin, ASWebAuthentication
4040
result(url.absoluteString)
4141
}
4242

43-
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler)
43+
var _session: ASWebAuthenticationSession? = nil
44+
if #available(macOS 14.4, *) {
45+
_session = ASWebAuthenticationSession(url: url, callback: ASWebAuthenticationSession.Callback.customScheme(callbackURLScheme), completionHandler: completionHandler)
46+
} else {
47+
_session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler)
48+
}
49+
let session = _session!
50+
4451
if let preferEphemeral = options["preferEphemeral"] as? Bool {
4552
session.prefersEphemeralWebBrowserSession = preferEphemeral
4653
}

0 commit comments

Comments
 (0)