Last active
October 23, 2021 16:27
-
-
Save rslifka/3caefdbaad6c1306d9d52886bdbbad1a to your computer and use it in GitHub Desktop.
Obtaining a reference to an ASPresentationAnchor for use with ASWebAuthenticationSession in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var window: UIWindow { | |
guard | |
let scene = UIApplication.shared.connectedScenes.first, | |
let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate, | |
let window = windowSceneDelegate.window as? UIWindow | |
else { | |
return UIWindow() | |
} | |
return window | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The source for this is Kilo Loco's AWS Amplify Auth Web UI for iOS | SwiftUI 2.0, Xcode 12 video. It's the only place I've been able to discover how ASPresentationAnchor might be obtainable in SwiftUI.
I'm a complete Xcode/Swift/SwiftUI/iOS novice so I have no idea if there's a different/better/easier way to do this. Please comment if so :)