2

I am building an iPad app to be used in a public multi-user scenario and want to allow temporary web browsing sessions. However, when the session is finished, I want the app to clear all private browsing data including cache, cookies and history.

I have figured out how to clear the cache and the cookies, but the history is eluding me.

Just to be clear, I'm not looking to clear the back/forward history of the UIWebView (I am creating a new instance of UIWebView each time so that isn't an issue). I am looking to clear the entire application's browsing history, so that links do not appear visited.

For example, if I search for something on Google and visit one of the hits, the link turns purple the next time I Google it. I want all history and past web pages to be erased so that no links stay purple after the browsing session is reset.

Alternatively, if I could just entirely disable history tracking (like a "private browsing mode" à la Chrome or Firefox) that would also be acceptable.

Update: Interestingly, I noticed that quitting and restarting the app implicitly clears the browsing history, and links once again appear blue upon startup. However, this unfortunately doesn't help me at all because the app is designed and intended to be run for long periods of time across many users. We can't quit the app after each session.

Update 2: Further experimentation shows that the web history is definitely maintained on a per-application basis. I googled the same thing in Safari and the links that show purple each time in my app appear blue in Safari. There has to be a way to access this local storage from within the app.

devios1
  • 36,899
  • 45
  • 162
  • 260
  • I don't think that history persists between instances. Can you just remove the webview from the superview, create a new one, and add it back in? – Aaron Brager Nov 04 '13 at 19:14
  • @AaronBrager No, it definitely persists (not the back/forward list, but the previously visited sites). I am creating a new instance of the webView between sessions. – devios1 Nov 04 '13 at 19:48
  • @devios1 As I am facing same issue, have you got any solutions to clear the browser history? – jigs May 24 '19 at 08:41
  • @jigs Sorry I don't believe I ever figured it out – devios1 May 27 '19 at 19:47

1 Answers1

1

If you are willing to use private frameworks, there is a discussion about this here: How to clear back forward list in UIWebview on iPhone?

If thats not an option for you, then the only other option I can think of would be deleting the webview and then recreating it.

Community
  • 1
  • 1
woody121
  • 358
  • 3
  • 14
  • I *am* deleting it and recreating it. The visited sites history persists until the app is killed. Also, I need it to be accepted by the App Store. – devios1 Nov 04 '13 at 19:48
  • Doesnt look like its possible then my friend - see http://stackoverflow.com/questions/9181098/i-want-to-create-an-action-that-allows-my-users-to-delete-uiwebview-history – woody121 Nov 04 '13 at 19:53