Create a web browser without tracking in the app

I am trying to create a webview (as an exercise) that does not track or save the browsing history locally. I made it so that when the webview is closed, it calls the following

[[NSURLSession sharedSession]resetWithCompletionHandler:^{}]; 

but I find that things like google search history are saved both between sessions. I also tried to clear the cookie separately through

 NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (NSHTTPCookie *cookie in [storage cookies]) { [storage deleteCookie:cookie]; } [[NSUserDefaults standardUserDefaults] synchronize]; 

still to no avail. Google searches still appear when creating a new web view.
Does anyone know how to remove the id used by Google to match my search history to me? I am worried about something like a package identifier, which is probably a little harder not to read.
Any ideas are welcome. Yours faithfully,
Luke

+5
source share
2 answers

Try setting nonPersistentDataStore for WKWebsiteDataStore WKWebViewConfiguration

Here is an example code snippet

 let webVuConfiguration = WKWebViewConfiguration() webVuConfiguration.websiteDataStore =WKWebsiteDataStore.nonPersistentDataStore() let webView = WKWebView(frame: webviewRect, configuration: webVuConfiguration) 
+2
source

To compliment Durai Amuthan.H on answering, here is the answer for us plebeians who still love to use Obj-C

 WKWebViewConfiguration * config = [WKWebViewConfiguration new]; config.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore]; webView = [[WKWebView alloc]initWithFrame:viewFrame configuration:config]; 
0
source

Source: https://habr.com/ru/post/1265856/


All Articles