From 56d57b4197216ebfdbbd3208743286f770b1df18 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:13:26 -0500 Subject: [PATCH] fix uidlegate --- .../NavigationDelegateProxyAPIDelegate.swift | 4 +- .../UIDelegateProxyAPIDelegate.swift | 68 +++++++++++-------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/NavigationDelegateProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/NavigationDelegateProxyAPIDelegate.swift index 2d53c23f130..748463d6b65 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/NavigationDelegateProxyAPIDelegate.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/NavigationDelegateProxyAPIDelegate.swift @@ -123,7 +123,7 @@ extension NavigationDelegateImpl { registrar.dispatchOnMainThread { onFailure in self.api.decidePolicyForNavigationResponse( pigeonInstance: self, webView: webView, navigationResponse: navigationResponse - ) { @MainActor result in + ) { result in DispatchQueue.main.async { switch result { case .success(let policy): @@ -161,7 +161,7 @@ extension NavigationDelegateImpl { registrar.dispatchOnMainThread { onFailure in self.api.didReceiveAuthenticationChallenge( pigeonInstance: self, webView: webView, challenge: challenge - ) { @MainActor result in + ) { result in DispatchQueue.main.async { switch result { case .success(let response): diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/UIDelegateProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/UIDelegateProxyAPIDelegate.swift index 2aeeff8477d..58d78bdb32e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/UIDelegateProxyAPIDelegate.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/UIDelegateProxyAPIDelegate.swift @@ -55,20 +55,22 @@ extension UIDelegateImpl { self.api.requestMediaCapturePermission( pigeonInstance: self, webView: webView, origin: origin, frame: frame, type: wrapperCaptureType - ) { @MainActor result in - switch result { - case .success(let decision): - switch decision { - case .deny: + ) { result in + DispatchQueue.main.async { + switch result { + case .success(let decision): + switch decision { + case .deny: + decisionHandler(.deny) + case .grant: + decisionHandler(.grant) + case .prompt: + decisionHandler(.prompt) + } + case .failure(let error): decisionHandler(.deny) - case .grant: - decisionHandler(.grant) - case .prompt: - decisionHandler(.prompt) + onFailure("WKUIDelegate.requestMediaCapturePermission", error) } - case .failure(let error): - decisionHandler(.deny) - onFailure("WKUIDelegate.requestMediaCapturePermission", error) } } } @@ -81,11 +83,13 @@ extension UIDelegateImpl { registrar.dispatchOnMainThread { onFailure in self.api.runJavaScriptAlertPanel( pigeonInstance: self, webView: webView, message: message, frame: frame - ) { @MainActor result in - if case .failure(let error) = result { - onFailure("WKUIDelegate.runJavaScriptAlertPanel", error) + ) { result in + DispatchQueue.main.async { + if case .failure(let error) = result { + onFailure("WKUIDelegate.runJavaScriptAlertPanel", error) + } + completionHandler() } - completionHandler() } } } @@ -97,13 +101,15 @@ extension UIDelegateImpl { registrar.dispatchOnMainThread { onFailure in self.api.runJavaScriptConfirmPanel( pigeonInstance: self, webView: webView, message: message, frame: frame - ) { @MainActor result in - switch result { - case .success(let confirmed): - completionHandler(confirmed) - case .failure(let error): - completionHandler(false) - onFailure("WKUIDelegate.runJavaScriptConfirmPanel", error) + ) { result in + DispatchQueue.main.async { + switch result { + case .success(let confirmed): + completionHandler(confirmed) + case .failure(let error): + completionHandler(false) + onFailure("WKUIDelegate.runJavaScriptConfirmPanel", error) + } } } } @@ -118,13 +124,15 @@ extension UIDelegateImpl { self.api.runJavaScriptTextInputPanel( pigeonInstance: self, webView: webView, prompt: prompt, defaultText: defaultText, frame: frame - ) { @MainActor result in - switch result { - case .success(let response): - completionHandler(response) - case .failure(let error): - completionHandler(nil) - onFailure("WKUIDelegate.runJavaScriptTextInputPanel", error) + ) { result in + DispatchQueue.main.async { + switch result { + case .success(let response): + completionHandler(response) + case .failure(let error): + completionHandler(nil) + onFailure("WKUIDelegate.runJavaScriptTextInputPanel", error) + } } } }