Experimental plugin to switch the webview and origin at runtime. Please read warning before using it in production apps.
If callbacks from plugins fire after reloading the webview, the app will crash.
Use with caution!
load() the main view in the app will restart!
iOS only now
WebViews must be installed as plugins such as:
Install WKWebview plugin(s) and configure it as default in config.xml:
WebviewSwitch which has the funtion
load()to switch the Cordova webview (plugin).
- Switch to default Cordova UIWebview at runtime:
- Switch to WKWebview at runtime:
- The In-App-Browser plugin works too and shares the session. But don´t forget to set
usewkwebviewto the correct value if you need a shared session.
iOS only now
⚠️ This is just useful as a workaround for a webkit bug and may break anytime!
You should avoid this method, since it reloads the webview as well. But it can be a workaround for this webkit bug, which prevents apps running in Ionic webview from using cookies. Handle with care since it might affect your applications security and stability.
The Ionic webview plugin runs on a custom scheme. The default scheme is
ionic://localhost, which can be changed at buildtime by setting
<preference name="Hostname" value="app" /> in config.xml.
If you need to change the hostname at runtime (for example for CORS issues for domains that can be configured in the app), this plugins offers the
If you change the hostname like this
WebviewSwitch.setHostname('myserver.com'), the app will reload and run with the origin
ionic://myserver.com. This will treat HTTP requests to
myserver.com as same-origin in current iOS.