@@ -18,6 +18,7 @@ final class GithubAuthenticationService: NSObject, AuthenticationService {
1818 private let messaging = Messaging . messaging ( )
1919 private var user : User ? { Auth . auth ( ) . currentUser }
2020 private let providerID = AuthProviderID . gitHub
21+ private let provider = TopViewControllerProvider ( )
2122 private let logger = Logger ( category: " GithubAuthService " )
2223
2324 func signIn( ) async throws -> AuthenticationDataResponse {
@@ -143,6 +144,7 @@ final class GithubAuthenticationService: NSObject, AuthenticationService {
143144 }
144145 }
145146
147+ @MainActor
146148 func requestAuthorizationCode( ) async throws -> String {
147149 guard let clientID = Bundle . main. object ( forInfoDictionaryKey: " GITHUB_CLIENT_ID " ) as? String ,
148150 let redirectURL = Bundle . main. object ( forInfoDictionaryKey: " APP_REDIRECT_URL " ) as? String ,
@@ -248,12 +250,7 @@ final class GithubAuthenticationService: NSObject, AuthenticationService {
248250
249251extension GithubAuthenticationService : ASWebAuthenticationPresentationContextProviding {
250252 func presentationAnchor( for session: ASWebAuthenticationSession ) -> ASPresentationAnchor {
251- guard let window = UIApplication . shared. connectedScenes
252- . flatMap ( { ( $0 as? UIWindowScene ) ? . windows ?? [ ] } )
253- . first ( where: { $0. isKeyWindow } ) else {
254- return ASPresentationAnchor ( )
255- }
256- return window
253+ return provider. keyWindow ( ) ?? ASPresentationAnchor ( )
257254 }
258255
259256 struct GitHubUser : Codable {
0 commit comments