Reputation: 575
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.
Upvotes: 10
Views: 4917
Reputation: 2614
Private browsing in iOS using WKWebView
As per apple documentation: To support private browsing,create a data store object and assign it to the websiteDataStore property of a WKWebViewConfiguration object before you create your web view. The default() method returns the default data store that saves website data persistently to disk. To implement private browsing, create a nonpersistent data store using the nonPersistent() method instead.
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)
Upvotes: 2
Reputation: 284
Set nonpersistentdatastore
for wkwebsitedatastore
for wkwebviewconfiguration
for wkwebview
Set NSURLrequestreloadcacheignoringlocalandremotecachedata
for NSURlrequest
in uiwebview
Reference
Creating a non-tracking in-app web browser
Upvotes: 12