All Projects → oracle → Cordova Plugin Wkwebview File Xhr

oracle / Cordova Plugin Wkwebview File Xhr

Licence: other
Cordova Plugin for WebView File XHR

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cordova Plugin Wkwebview File Xhr

Wifiwizard2
A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
Stars: ✭ 106 (-8.62%)
Mutual labels:  cordova, cordova-plugin
Unityionicintegration
A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
Stars: ✭ 94 (-18.97%)
Mutual labels:  cordova, cordova-plugin
Awesome Cordova Plugins
A curated list of awesome Cordova Apache Plugins https://cordova.apache.org/plugins/
Stars: ✭ 33 (-71.55%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Linkedin
Cordova plugin for LinkedIn
Stars: ✭ 17 (-85.34%)
Mutual labels:  cordova, cordova-plugin
Google Analytics Plugin
Cordova Google Analytics Plugin for Android & iOS
Stars: ✭ 90 (-22.41%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Disable Bitcode
Cordova plugin to disable bitcode in iOS build settings
Stars: ✭ 19 (-83.62%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Add Swift Support
🔨 Swiftify your Cordova app !
Stars: ✭ 108 (-6.9%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Qrscanner
A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
Stars: ✭ 485 (+318.1%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Wechat
A cordova plugin, a JS version of Wechat SDK
Stars: ✭ 1,198 (+932.76%)
Mutual labels:  cordova, cordova-plugin
Blinkid Cordova
ID scanning for cross-platform apps built with Cordova and Phonegap.
Stars: ✭ 44 (-62.07%)
Mutual labels:  cordova, cordova-plugin
Cordova Admob Pro
🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.
Stars: ✭ 690 (+494.83%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Remote Injection
DEPRECATED: Cordova plugin to allow a remote site to interact with cordova's javascript APIs when loaded within a cordova app.
Stars: ✭ 90 (-22.41%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Camera Preview
Cordova plugin that allows camera interaction from HTML code
Stars: ✭ 528 (+355.17%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Permissionscope
🔓 Cordova plugin to handle iOS permissions
Stars: ✭ 27 (-76.72%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Admob Free
Cordova AdMob Plugin
Stars: ✭ 508 (+337.93%)
Mutual labels:  cordova, cordova-plugin
Cl.kunder.webview
This cordova plugin enables you to open a second webview
Stars: ✭ 36 (-68.97%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Geofence
Geofencing plugin for cordova
Stars: ✭ 261 (+125%)
Mutual labels:  cordova, cordova-plugin
Vue Cordova
Vue.js plugin for Cordova
Stars: ✭ 328 (+182.76%)
Mutual labels:  cordova, cordova-plugin
Ionic4
This repo contains example code for ionic4. Get Step by Step tutorial of this repo examples using https://ampersandacademy.com/tutorials/ionic-framework-4
Stars: ✭ 37 (-68.1%)
Mutual labels:  cordova, cordova-plugin
Cordova Broadcaster
Cordova Plugin to allow message exchange between javascript and native (and viceversa)
Stars: ✭ 104 (-10.34%)
Mutual labels:  cordova, cordova-plugin

cordova-plugin-wkwebview-file-xhr 3.0.0

About the cordova-plugin-wkwebview-file-xhr

This plugin makes it possible to reap the performance benefits of using the WKWebView in your Cordova app by resolving the following issues:

  • The default behavior of WKWebView is to raise a cross origin exception when loading files from the main bundle using the file protocol - "file://". This plugin works around this shortcoming by loading files via native code if the web view's current location has "file" protocol and the target URL passed to the open method of the XMLHttpRequest is relative. As a security measure, the plugin verifies that the standardized path of the target URL is within the "www" folder of the application's main bundle or in the /Library path of the application data directory.

  • Since the application's starting page is loaded from the device's file system, all XHR requests to remote endpoints are considered cross origin. For such requests, WKWebView specifies "null" as the value of the Origin header, which will be rejected by endpoints that are configured to disallow requests from the null origin. This plugin works around that issue by handling all remote requests at the native layer where the origin header will be excluded.

Installation

Plugin installation requires Cordova 4+ and iOS 9+. It will install the Apache Cordova WKWebView plugin cordova-plugin-wkwebview-engine.

cordova plugin add cordova-plugin-wkwebview-file-xhr

Note : If your cordova-ios version is less than 6.0.0. You need to add following dependency to plugin.xml

<dependency id="cordova-plugin-wkwebview-engine" />

Alternatively you can use this plugin's version 2.1.4

Supported Platforms

  • iOS

Quick Example

// read local resource
var xhr = new XMLHttpRequest();
xhr.addEventListener("loadend", function(evt)
 {
   var data = this.responseText;
   document.getElementById("myregion").innerHTML = data;
 });

xhr.open("GET", "js/views/customers.html");
xhr.send();

// post to remote endpoint
var xhr = new XMLHttpRequest();
xhr.addEventListener("loadend", function(evt)
 {
   var product = this.response;
   document.getElementById("productId").value = product.id;
   document.getElementById("productName").value = product.name;
 });

xhr.open("POST", "https://myremote/endpoint/product");
xhr.responseType = "json";
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send(JSON.stringify({name: "Product 99"}));

Configuration

The following configuration options modify the default behavior of the plugin. The values are specified in config.xml as preferences:

  • AllowUntrustedCerts: on|off (default: off). If "on", requests routed to the native implementation will accept self signed SSL certificates. This preference should only be enabled for testing purposes.
  • InterceptRemoteRequests: all|secureOnly|none (default: secureOnly). Controls what types of remote XHR requests are intercepted and handled by the plugin. The plugin always intercepts requests with the file:// protocol. By default, the plugin will intercept only secure protocol requests ("https").
  • NativeXHRLogging: none|full (default: none). If "full" the javascript layer will produce logging of the XHR requests sent through the native to the javascript console. Note: natively routed XHR requests will not appear in the web inspector utility when "InterceptRemoteRequests" is "all" or "secureOnly".

Known Issues

The plugin caches cookies at the native layer between requests but it does not attempt to sync cookies between the WKWebView and the native sessions. From the JavaScript context, this means "document.cookie" won't contain any cookies returned from XHR handled at the native layer and the native iOS XHR will not see any cookies returned from remote resources fetched by the browser context, such as images.

Whilst this plugin resolves the main issues preventing the use of the Apache Cordova WKWebView plugin, there are other known issues with that plugin.

Changes

See CHANGELOG.

Contributing

This is an open source project maintained by Oracle Corp. Pull Requests are currently not being accepted. See CONTRIBUTING for details.

License

Copyright (c) 2018 Oracle and/or its affiliates The Universal Permissive License (UPL), Version 1.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].