Disable pop-up window - WKWebView SwiftUI

Viewed 17

It is possible to show websites with the help of UIKit and a WKWebView in SwiftUI:

import UIKit
import WebKit

class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string: "http://bla.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }


}

I know that you can disable cookies by writing:

myRequest.httpShouldHandleCookies = false

But is there a way to avoid showing the pop up window on websites and reject all cookies that are not needed?

0 Answers
Related