From cc0d187a4601bf8d6cd1f1470cf5d5c1d21878f9 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 16 May 2024 14:59:31 -0700 Subject: [PATCH] Fix two flow porting errors in AuthURLPresenter.swift --- .../Swift/Utilities/AuthURLPresenter.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/FirebaseAuth/Sources/Swift/Utilities/AuthURLPresenter.swift b/FirebaseAuth/Sources/Swift/Utilities/AuthURLPresenter.swift index 20de31ca968..a9a62bf88b2 100644 --- a/FirebaseAuth/Sources/Swift/Utilities/AuthURLPresenter.swift +++ b/FirebaseAuth/Sources/Swift/Utilities/AuthURLPresenter.swift @@ -84,6 +84,19 @@ return false } + // MARK: SFSafariViewControllerDelegate + + func safariViewControllerDidFinish(_ controller: SFSafariViewController) { + kAuthGlobalWorkQueue.async { + if controller == self.safariViewController { + // TODO: Ensure that the SFSafariViewController is actually removed from the screen + // before invoking finishPresentation + self.finishPresentation(withURL: nil, + error: AuthErrorUtils.webContextCancelledError(message: nil)) + } + } + } + // MARK: AuthWebViewControllerDelegate func webViewControllerDidCancel(_ controller: AuthWebViewController) { @@ -156,8 +169,8 @@ let webViewController = self.webViewController self.webViewController = nil if safariViewController != nil || webViewController != nil { - uiDelegate?.dismiss(animated: true) { - kAuthGlobalWorkQueue.async { + DispatchQueue.main.async { + uiDelegate?.dismiss(animated: true) { self.isPresenting = false if let completion { completion(url, error)