Creating a non-tracking in-app web browser

只谈情不闲聊 提交于 2019-12-09 06:00:06

问题


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

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

but I am finding that things like google search history persists some how between sessions. I have also tried clearing cookies 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 show when a new web view is created.
Is anyone aware of a way to remove the identifier that google is using to match that search history back to me? I'm concerned it's something like the bundle identifier, which is probably a bit trickier to prevent being read.
Any ideas are appreciated.
Regards,
Luke


回答1:


Try setting nonPersistentDataStore for WKWebsiteDataStore of WKWebViewConfiguration

Here is a sample code snippet

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



回答2:


To compliment Durai Amuthan.H's answer, here is the answer for us plebs who still like to use Obj-C

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


来源:https://stackoverflow.com/questions/42994553/creating-a-non-tracking-in-app-web-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!