@capgo/inappbrowser 7.16.5 → 7.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -752,8 +752,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
752
752
|
|
|
753
753
|
@objc func close(_ call: CAPPluginCall) {
|
|
754
754
|
DispatchQueue.main.async {
|
|
755
|
-
self.
|
|
756
|
-
|
|
755
|
+
let currentUrl = self.webViewController?.url?.absoluteString ?? ""
|
|
756
|
+
|
|
757
|
+
self.webViewController?.cleanupWebView()
|
|
758
|
+
|
|
759
|
+
self.navigationWebViewController?.dismiss(animated: true) {
|
|
760
|
+
self.webViewController = nil
|
|
761
|
+
self.navigationWebViewController = nil
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
self.notifyListeners("closeEvent", data: ["url": currentUrl])
|
|
757
765
|
call.resolve()
|
|
758
766
|
}
|
|
759
767
|
}
|
|
@@ -893,6 +893,34 @@ public extension WKWebViewController {
|
|
|
893
893
|
|
|
894
894
|
executeScript(script: script)
|
|
895
895
|
}
|
|
896
|
+
|
|
897
|
+
open func cleanupWebView() {
|
|
898
|
+
guard let webView = self.webView else { return }
|
|
899
|
+
webView.stopLoading()
|
|
900
|
+
// Break delegate callbacks early
|
|
901
|
+
webView.navigationDelegate = nil
|
|
902
|
+
webView.uiDelegate = nil
|
|
903
|
+
webView.loadHTMLString("", baseURL: nil)
|
|
904
|
+
|
|
905
|
+
webView.removeObserver(self, forKeyPath: estimatedProgressKeyPath)
|
|
906
|
+
if websiteTitleInNavigationBar {
|
|
907
|
+
webView.removeObserver(self, forKeyPath: titleKeyPath)
|
|
908
|
+
}
|
|
909
|
+
webView.removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
|
|
910
|
+
|
|
911
|
+
webView.configuration.userContentController.removeAllUserScripts()
|
|
912
|
+
webView.configuration.userContentController.removeScriptMessageHandler(forName: "messageHandler")
|
|
913
|
+
webView.configuration.userContentController.removeScriptMessageHandler(forName: "close")
|
|
914
|
+
webView.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptSuccess")
|
|
915
|
+
webView.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptError")
|
|
916
|
+
webView.configuration.userContentController.removeScriptMessageHandler(forName: "magicPrint")
|
|
917
|
+
|
|
918
|
+
webView.removeFromSuperview()
|
|
919
|
+
// Also clean progress bar view if present
|
|
920
|
+
progressView?.removeFromSuperview()
|
|
921
|
+
progressView = nil
|
|
922
|
+
self.webView = nil
|
|
923
|
+
}
|
|
896
924
|
}
|
|
897
925
|
|
|
898
926
|
// MARK: - Fileprivate Methods
|
|
@@ -941,7 +969,6 @@ fileprivate extension WKWebViewController {
|
|
|
941
969
|
if !(self.navigationController?.navigationBar.isHidden)! {
|
|
942
970
|
self.progressView?.frame.origin.y = CGFloat((self.navigationController?.navigationBar.frame.height)!)
|
|
943
971
|
self.navigationController?.navigationBar.addSubview(self.progressView!)
|
|
944
|
-
webView?.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)
|
|
945
972
|
}
|
|
946
973
|
}
|
|
947
974
|
|
|
@@ -1285,21 +1312,9 @@ fileprivate extension WKWebViewController {
|
|
|
1285
1312
|
canDismiss = delegate?.webViewController?(self, canDismiss: url) ?? true
|
|
1286
1313
|
}
|
|
1287
1314
|
if canDismiss {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
if websiteTitleInNavigationBar {
|
|
1292
|
-
webView?.removeObserver(self, forKeyPath: titleKeyPath)
|
|
1293
|
-
}
|
|
1294
|
-
webView?.removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
|
|
1295
|
-
webView?.configuration.userContentController.removeAllUserScripts()
|
|
1296
|
-
webView?.configuration.userContentController.removeScriptMessageHandler(forName: "messageHandler")
|
|
1297
|
-
webView?.configuration.userContentController.removeScriptMessageHandler(forName: "close")
|
|
1298
|
-
webView?.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptSuccess")
|
|
1299
|
-
webView?.configuration.userContentController.removeScriptMessageHandler(forName: "preShowScriptError")
|
|
1300
|
-
webView = nil
|
|
1301
|
-
|
|
1302
|
-
self.capBrowserPlugin?.notifyListeners("closeEvent", data: ["url": webView?.url?.absoluteString ?? ""])
|
|
1315
|
+
let currentUrl = webView?.url?.absoluteString ?? ""
|
|
1316
|
+
cleanupWebView()
|
|
1317
|
+
self.capBrowserPlugin?.notifyListeners("closeEvent", data: ["url": currentUrl])
|
|
1303
1318
|
dismiss(animated: true, completion: nil)
|
|
1304
1319
|
}
|
|
1305
1320
|
}
|
|
@@ -1327,8 +1342,9 @@ fileprivate extension WKWebViewController {
|
|
|
1327
1342
|
|
|
1328
1343
|
func close() {
|
|
1329
1344
|
let currentUrl = webView?.url?.absoluteString ?? ""
|
|
1330
|
-
|
|
1345
|
+
cleanupWebView()
|
|
1331
1346
|
capBrowserPlugin?.notifyListeners("closeEvent", data: ["url": currentUrl])
|
|
1347
|
+
dismiss(animated: true, completion: nil)
|
|
1332
1348
|
}
|
|
1333
1349
|
|
|
1334
1350
|
open func setUpNavigationBarAppearance() {
|