10

I am working on a incongnito browser.I am using wkwebview when I clear all the cookies I can see that popular search engine like google remembers the searches that has been made.

I tried cleaning all the cookies in NSHTTPCookieStorage and resetcookies using NSURLSession but its still not working.

4

2 回答 2

12

设置nonpersistentdatastorewkwebsitedatastore_ wkwebviewconfiguration_wkwebview

设置 NSURLrequestreloadcacheignoringlocalandremotecachedataNSURlrequest_uiwebview

参考

创建非跟踪应用内网络浏览器

于 2017-03-30T20:27:44.903 回答
1

使用 WKWebView 在 iOS 中进行隐私浏览

根据苹果文档要支持隐私浏览,请在创建 Web 视图之前创建一个数据存储对象并将其分配给 WKWebViewConfiguration 对象的 websiteDataStore 属性。default() 方法返回将网站数据持久保存到磁盘的默认数据存储。要实现隐私浏览,请改为使用 nonPersistent() 方法创建一个非持久性数据存储。

    let webConfiguration = WKWebViewConfiguration()
    webConfiguration.processPool = WKProcessPool()
    webConfiguration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
    let webView = WKWebView(frame: self.webContainerView.bounds, configuration: webConfiguration)
    // Set up request
    if let requestURL = URL(string: "enter_url_to_load") {
        var request = URLRequest(url: requestURL)
        request.httpShouldHandleCookies = false
        request.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData
        webView.navigationDelegate = self
        webView.load(request)
    }
    self.webContainerView.addSubview(webView)
于 2021-07-15T06:44:22.853 回答