npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-webview-switch

v0.3.0

Published

Switch wenbview implementation

Downloads

28

Readme

cordova-plugin-webview-switch

Experimental plugin to switch the webview and origin at runtime. Please read warning before using it in production apps.

Attention :warning:

This plugin only loads webviews, installed as plugins, like WKWebView or Ionic WKWebView. App crashes and incompatibilities with Cordova updates may occurr.

If callbacks from plugins fire after reloading the webview, the app will crash.

Use with caution!

After calling load() the main view in the app will restart!

Webview switching

iOS only now

WebViews must be installed as plugins such as:

Install WKWebview plugin(s) and configure it as default in config.xml:

<feature name="CDVWKWebViewEngine">
  <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

This plugin creates the global Javascript object WebviewSwitch which has the funtion load()to switch the Cordova webview (plugin).

Examples:

  • Switch to default Cordova UIWebview at runtime: WebviewSwitch.load('CDVUIWebViewEngine')
  • Switch to WKWebview at runtime: WebviewSwitch.load('CDVWKWebViewEngine')
  • The In-App-Browser plugin works too and shares the session. But don´t forget to set usewkwebview to the correct value if you need a shared session.

Hostname switching

iOS only now

:warning: 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 setHostname(name) method.

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.