How to delete WKWebview 's Cache in iOS8? For iOS 9 Below code was working.
let websiteDataTypes = NSSet(array: [WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeCookies])
let date = NSDate(timeIntervalSince1970: 0)
WKWebsiteDataStore.defaultDataStore().removeDataOfTypes(websiteDataTypes as! Set<String>, modifiedSince: date, completionHandler:{ })
For iOS 8, I tried solutions in following links, but Cache is not deleted.
How to remove cache in WKWebview?
remove cache in wkwebview objective c
How to delete WKWebview cookies
http://blogs.candoerz.com/question/128462/how-to-delete-wkwebview-cookies.aspx
http://atmarkplant.com/ios-wkwebview-tips/
I would appreciate your help.
I am working on browser for iOS and wanna to share our experience in that question.
First of all, all webviews in our browser connected between each other via single processPool. It leads to sharing cookies between all webViews. To do this, we set same processPool to WKWebViewConfiguration, that is passed to newly created webView:
Secondly, the process of data removing looks like this:
Remove all created webViews
Remove directories with cache/cookies
Create new process pool
Recreate webViews with new process pool
If you have 1 webView, the whole process should look like this:
I want to draw your attention, that this code works only on device in iOS 8.x. It doesn't work in simulator at all.