How to delete WKWebview's Cache in iOS8?

Dear Apple,


The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?

#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.


Thanks,

Phong Tran.

I tried somthing and it working as well in iOS 9 upwards.

What did you try?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

let websiteDataTypes = WKWebsiteDataStore.allWebsiteDataTypes()            
let date = NSDate(timeIntervalSince1970: 0)
            
WKWebsiteDataStore.defaultDataStore().removeDataOfTypes(websiteDataTypes, modifiedSince: date, completionHandler: {                
  #if DEBUG  
  print("remove all data in iOS9 later")
  #endif            
})

haven't tested yet, just saw this answer, in case someone in the future needs it https://gist.github.com/dakeshi/6915b6681cbc29327dcc9b27cef263b8#:~:text=Use%20an%20default%20WKWebView%20save%20all%20caches%2C%20cookies,method%20when%20the%20app%20receives%20the%20memory%20warning.

How to delete WKWebview's Cache in iOS8?
 
 
Q