Reputation: 1488
I'm creating an app where you can open google to find a solution on an answer:
ref = cordova.InAppBrowser.open('https://google.nl/', '_blank', 'clearsessioncache=yes, clearcache=yes');
Despite I send the properties clearsessioncache=yes, clearcache=yes and I'm not logged in on Google it keeps showing previous search results when I enter the search box.
Can someone explain why the history keeps showing in the 'suggested' sites? And if there is any way to prevent this.
Upvotes: 0
Views: 683
Reputation: 1488
Found the answer myself. Hope it helps someone else with the same problem:
Google search history is stored in localStorage. So clearing localStorage before showing the InAppBrowser solves the problem:
this.ref = cordova.InAppBrowser.open('https://www.google.nl/', '_blank', 'clearsessioncache=yes,clearcache=yes,closebuttoncaption=Terug,closebuttoncolor=#4286f4,hideurlbar=yes,hidden=yes');
this.ref.addEventListener('loadstop', () => {
var init = false
this.ref.addEventListener('loadstop', () => {
if (!init) {
// clear localStorage to clear Google search history
this.ref.executeScript({
code: `
(function() {
localStorage.clear();
return true;
})()` }, _ => {
// cache is cleared. Now we can show the browser.
this.ref.show();
init = true;
});
}
});
});
Upvotes: 2