Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear history in WKWebView?

I'd like to clear the back forward list of a WKWebView when the user taps a button.

I can't find anything useful in Apple documentation but I found the same question related to UIWebView : How to clear back forward list in UIWebview on iPhone?

Unfortunately, I don't really like the given answers as they are either risky considering the app review process or they just don't work. So I was wondering if there was something new with WKWebView that could help me to achieve that. I'm kind of hopeless as it's been a while now that I'm looking for a solution but we never know...

like image 868
Randy Avatar asked Jul 18 '16 12:07

Randy


1 Answers

Dirty workaround

For now, I reinitialise my WKWebView ( myWebView = WKWebView() ) and I redefine its constraints ( as they are, of course, broken when I reinitialise the web view ).

What I don't really like here is that I reinitialise the whole web view whereas I just want to clear its back forward list.

like image 156
Randy Avatar answered Nov 04 '22 11:11

Randy