Skip to content

Commit

Permalink
Enable partial ASWebAuthenticationSession.Callback support
Browse files Browse the repository at this point in the history
Related: #104
  • Loading branch information
ThexXTURBOXx committed Jun 5, 2024
1 parent c7c0c19 commit 67e1e9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ public class SwiftFlutterWebAuth2Plugin: NSObject, FlutterPlugin {
}

if #available(iOS 12, *) {
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler!)
var _session: ASWebAuthenticationSession? = nil
if #available(iOS 17.4, *) {
_session = ASWebAuthenticationSession(url: url, callback: ASWebAuthenticationSession.Callback.customScheme(callbackURLScheme), completionHandler: completionHandler!)
} else {
_session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler!)
}
let session = _session!

if #available(iOS 13, *) {
var rootViewController: UIViewController? = nil
Expand Down
9 changes: 8 additions & 1 deletion flutter_web_auth_2/macos/Classes/FlutterWebAuth2Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public class FlutterWebAuth2Plugin: NSObject, FlutterPlugin, ASWebAuthentication
result(url.absoluteString)
}

let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler)
var _session: ASWebAuthenticationSession? = nil
if #available(macOS 14.4, *) {
_session = ASWebAuthenticationSession(url: url, callback: ASWebAuthenticationSession.Callback.customScheme(callbackURLScheme), completionHandler: completionHandler)
} else {
_session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme, completionHandler: completionHandler)
}
let session = _session!

if let preferEphemeral = options["preferEphemeral"] as? Bool {
session.prefersEphemeralWebBrowserSession = preferEphemeral
}
Expand Down

0 comments on commit 67e1e9e

Please sign in to comment.