Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova: restart app and clear browser history

Tags:

We are adding a feature to our Cordova app to catch unhandled exceptions and restart the app. We would like the browser history to be cleared in this case so the user can't hit back on an Android device to go back to the screen that crashed.

It isn't possible to clear the browser history programmatically, but I expected there to be a Cordova plugin that reinstantiates the whole app (i.e. deletes the current webview and creates a new one). I wasn't able to find anything like this though.

Is there a good way to do this that will work on both iOS and Android?

like image 735
Matthew Gertner Avatar asked Aug 15 '18 11:08

Matthew Gertner


1 Answers

In Android for every WebView instance you can do:

webView.clearCache(true);
webView.clearHistory();
webView.clearFormData();

For IOS please read here: Clearing UIWebview cache

like image 52
RonTLV Avatar answered Sep 28 '22 05:09

RonTLV