Skip to content

Commit

Permalink
fix: revert GPT useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Aug 28, 2024
1 parent 18770f5 commit dd11382
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
8 changes: 2 additions & 6 deletions ios/Plugin/InAppBrowserPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public class InAppBrowserPlugin: CAPPlugin {
let closeModalOk = call.getString("closeModalOk", "OK")
let closeModalCancel = call.getString("closeModalCancel", "Cancel")
let isInspectable = call.getBool("isInspectable", false)
let preventDeeplink = call.getBool("preventDeeplink", false)
let isAnimated = call.getBool("isAnimated", true)

var disclaimerContent = call.getObject("shareDisclaimer")
Expand All @@ -142,11 +141,10 @@ public class InAppBrowserPlugin: CAPPlugin {
let url = URL(string: urlString)

if self.isPresentAfterPageLoad {
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable, preventDeeplink: preventDeeplink)
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
} else {
self.webViewController = WKWebViewController.init()
self.webViewController?.setHeaders(headers: headers)
self.webViewController?.setPreventDeeplink(preventDeeplink: preventDeeplink)
}

self.webViewController?.source = .remote(url!)
Expand Down Expand Up @@ -252,7 +250,6 @@ public class InAppBrowserPlugin: CAPPlugin {
}

let isInspectable = call.getBool("isInspectable", false)
let preventDeeplink = call.getBool("preventDeeplink", false)

self.currentPluginCall = call

Expand All @@ -274,11 +271,10 @@ public class InAppBrowserPlugin: CAPPlugin {
let url = URL(string: urlString)

if self.isPresentAfterPageLoad {
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable, preventDeeplink: preventDeeplink)
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
} else {
self.webViewController = WKWebViewController.init()
self.webViewController?.setHeaders(headers: headers)
self.webViewController?.setPreventDeeplink(preventDeeplink: preventDeeplink)
}

self.webViewController?.source = .remote(url!)
Expand Down
13 changes: 2 additions & 11 deletions ios/Plugin/WKWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import WebKit
private let estimatedProgressKeyPath = "estimatedProgress"
private let titleKeyPath = "title"
private let cookieKey = "Cookie"
private let preventDeeplink: Bool = false

private struct UrlsHandledByApp {
static var hosts = ["itunes.apple.com"]
Expand Down Expand Up @@ -61,11 +60,10 @@ open class WKWebViewController: UIViewController {
self.initWebview()
}

public init(url: URL, headers: [String: String], isInspectable: Bool, preventDeeplink: Bool) {
public init(url: URL, headers: [String: String], isInspectable: Bool) {
super.init(nibName: nil, bundle: nil)
self.source = .remote(url)
self.setHeaders(headers: headers)
self.preventDeeplink = preventDeeplink
self.initWebview(isInspectable: isInspectable)
}

Expand Down Expand Up @@ -106,6 +104,7 @@ open class WKWebViewController: UIViewController {
}
}


internal var customUserAgent: String? {
didSet {
guard let agent = userAgent else {
Expand Down Expand Up @@ -807,10 +806,6 @@ extension WKWebViewController: WKNavigationDelegate {
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
var actionPolicy: WKNavigationActionPolicy = .allow

if self.preventDeeplink {
actionPolicy = .preventDeeplinkActionPolicy
}

defer {
decisionHandler(actionPolicy)
}
Expand Down Expand Up @@ -845,7 +840,3 @@ class BlockBarButtonItem: UIBarButtonItem {

var block: ((WKWebViewController) -> Void)?
}

extension WKNavigationActionPolicy {
static let preventDeeplinkActionPolicy = WKNavigationActionPolicy(rawValue: WKNavigationActionPolicy.allow.rawValue + 2)!
}

0 comments on commit dd11382

Please sign in to comment.