Closed longinius closed 2 years ago
This means the README must also be updated, and since it's likely a breaking change for existing users, maybe it should allows to keep the old behavior but fallback to the new one?
Yes, you are right that it is incompatible with the previous version and is basically a breaking change. With version 5.3.1 the change was introduced, the previous version 5.3.0 works fine with SwiftUI, because there the ASPresentationAnchor is used.
I will update the pull request and provide a solution which allows to pass an ASPresentationAnchor or alternatively a UIViewController as context. So we should have all possibilities covered.
I haven't explicitly tested the variant with the UIViewController, but it's basically the same code only with the ASPresentationAnchor checked before it falls back to the UIViewController.
With this customization you can pass a UIViewController as before or alternatively an ASPresentationAnchor for SwiftUI or a UIWindow directly as context.
Is this still alive? We are looking forward to this change to use it in SwiftUI
The type of the presentation anchor for the
ASWebAuthenticationSession
needs to be anASPresentationAnchor
to work with SwiftUI. The change was introduced in 5.3.1, version 5.3.0 worked perfectly fine with SwiftUI.In a pure SwiftUI app it's not easy (is it even possible?) to get a reference for a
UIWindow
.With this change it's possible to provide an
ASPresentationAnchor
in SwiftUI like:UIKit applications can provide a reference to a
UIWindow
since theASPresentationAnchor
is a typealias of theUIWindow
. So instead of getting theUIWindow
reference from aUIViewController
, provide a reference to aUIWindow
directly to theauthorizeContext
.