cordova-plugin-ionic-webview
cordova-plugin-ionic-webview copied to clipboard
Using backbutton causes refresh on android
I'm using this plugin without using the entire ionic stack.
When pressing the back button before using this plugin I was able to register the backbutton
event using the cordova device class and the functionality worked as expected.
After adding this plug-in this functionaloty was changed and I can't find anything in the documentation to understand how to change this behavior when not using ionic.
Code can be seen here:
https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.Web/sources/application/services/application-exit.service.ts
Seems like the cause of this is the fact that the above code is using history.back()
when pressing the back button.
This behavior does not happen when not using ionic-webview - i.e. history.back()
doesn't do anything when there's no history. this is also true for regular browsing i.e. if I open a tab with no history calling history.back()
doesn't do anything.
I have this problem too, it seems that when the user try to load file:///android_asset/www/index.html
then the url http://localhost/
is loaded so the history look like this :
0 => file:///android_asset/www/index.html
1 => http://localhost/
When the user press back, it tries to go to file:///android_asset/www/index.html
and is redirected to http://localhost/
again.
My workaround is to call window.navigator.app.clearHistory()
once at start, then the history would look like this :
0 => http://localhost/
So this way the history is clean when the user try to press back and the app exit normally.
just now had tested
<content src="https://localhost/index.html" />
in config.xml. Seems it's works properly if you set like this.
Hi, I had see same issue. Removing the cordova-plugin-splashscreen for Android fixed my problem. It doesn't seem to work well with the ionic webview plugin.
You can use my forked plugin. I removed the Anroid parts: https://github.com/dev-gml/cordova-plugin-splashscreen#noAndroid504
Hope that helps.