From 50349975e5a0b81595f6f91ea0747910cf9c7aeb Mon Sep 17 00:00:00 2001 From: malua Date: Mon, 30 Dec 2024 14:16:17 +0100 Subject: [PATCH] feat: add ability to close webview from javascript on ios --- ios/Plugin/WKWebViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/Plugin/WKWebViewController.swift b/ios/Plugin/WKWebViewController.swift index 3141567..83c2867 100644 --- a/ios/Plugin/WKWebViewController.swift +++ b/ios/Plugin/WKWebViewController.swift @@ -267,6 +267,8 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler { } print("[InAppBrowser - preShowScriptError]: Error!!!!") semaphore.signal() + } else if message.name == "close" { + closeView() } } @@ -299,6 +301,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler { userContentController.add(self, name: "messageHandler") userContentController.add(self, name: "preShowScriptError") userContentController.add(self, name: "preShowScriptSuccess") + userContentController.add(self, name: "close") webConfiguration.userContentController = userContentController let webView = WKWebView(frame: .zero, configuration: webConfiguration)