Coder Social home page Coder Social logo

rickgbw / cordova-plugin-webview-checker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nonameprovided/cordova-plugin-webview-checker

0.0 1.0 0.0 13 KB

Checks whether Android System Webview is installed and enabled or not

License: MIT License

Java 72.15% JavaScript 27.85%

cordova-plugin-webview-checker's Introduction

cordova-plugin-webview-checker

Checks whether Android System WebView is enabled or not.

Installation

cordova plugin add cordova-plugin-webview-checker

Usage

As this plugin is used to detect the version of the WebView before launching your app, it should not be used in your application code, but directly added to index.html via a script tag to render an error state if the required WebView is not present.

Notes

The Android System WebView was first shipped in Android 4.4 (KitKat) and based on Chrome for Android 30. Every phone which comes with Google Play installed has it From Android 4.4. In Android 5.0 (Lollipop) the WebView has been decoupled from the OS and become updatable through the Play Store. Above Android 7.0 the Android System WebView will be disabled and won't be updated as long as Chrome is installed and enabled.

Pre-installed Versions

Every Android release since Android 4.4 (KitKat) comes pre-installed with Android System WebView. The pre-installed versions are the followings:

  • Android 4.4 (KitKat) - Android System WebView 30.0.0.0
  • Android 4.4.3 - Android System WebView 33.0.0.0
  • Android 5.0 (Lollipop) - Android System WebView 37.0.0.0
  • Android 6.0 (Marshmallow) - Android System WebView 44.0.2403.117
  • Android 7.0 (Nougat) - disabled by default as Chrome 51+ is used for rendering
  • Android 8.0 (Oreo) - disabled by default as Chrome 51+ is used for rendering

Usage of language features above ES5

In short, do not use anything else than ES5 to write your handler logic for this plugin and do not bundle it into your main application. The reason for this is that the older versions which are shipped do not support most of the ES6+ features and can only interpret ES5 code.

Also do not pass the console function as a parameter like .then(console.log), this will cause an Uncaught TypeError: Illegal invocation error in older versions of the Android System WebView.

API

isWebViewEnabled()

It returns a promise which will be resolved to true if the Android System Webview is enabled and false otherwise.

Technically all Android phone has Android System WebView installed but when it's disabled it will defaults to the version shipped with the phone. So you should determine a minimal required version and use plugins.chromeWebviewChecker.getChromeWebviewVersion to check if the installed version is higher or not.

plugins.webViewChecker.isWebViewEnabled()
  .then(function(enabled) { console.log(enabled); }))
  .catch(function(error) { console.error(error); }));

getWebViewVersion()

It returns a promise which will be resolved to the string representation of the version number (eg: 57.0.2987.132) or rejected with a Package is not found error if the Android System Webview is not installed

plugins.webViewChecker.getWebViewVersion()
  .then(function(version) { console.log(version); }))
  .catch(function(error) { console.error(error); }));

openGooglePlayPage()

A helper function to open the Google Play page of Android System Webview. Useful for prompting the user to update/enable the Android System Webview.

plugins.webViewChecker.openGooglePlayPage()
  .then(function() { console.log('Google Play page of Android System Webview has been opened.'); }))
  .catch(function(error) { console.error(error); }));

cordova-plugin-webview-checker's People

Contributors

nonameprovided avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.