I ran into an unexpected problem: authConfig.authorizeContext will not accept a UIWindow, and instead must be a UIViewController.
This is the implementation of presentationAnchor:
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
guard let context = authorizer.oauth2.authConfig.authorizeContext as? UIViewController else {
fatalError("Invalid authConfig.authorizeContext, must be a UIViewController but is \(String(describing: authorizer.oauth2.authConfig.authorizeContext))")
}
return context.view.window!
}
However, if we look at the definition of ASPresentationAnchor:
public typealias ASPresentationAnchor = UIWindow
it is in fact a UIWindow.
The implementation of presentationAnchor is befuddling:
it is supposed to return a UIWindow
but it casts authConfig.authorizeContext as a UIViewController, then returns its view's window
This is a bit contrived. Why not just accept a UIWindow via authConfig.authorizeContext in the first place?
I ran into an unexpected problem:
authConfig.authorizeContext
will not accept a UIWindow, and instead must be a UIViewController.This is the implementation of
presentationAnchor
:However, if we look at the definition of
ASPresentationAnchor
:it is in fact a UIWindow.
The implementation of
presentationAnchor
is befuddling:UIViewController
, then returns its view'swindow
This is a bit contrived. Why not just accept a UIWindow via
authConfig.authorizeContext
in the first place?