Basic Cordova setup
You need to install an inappbrowser plugin .
cordova plugin add cordova-plugin-inappbrowser
For future versions of the plugin, you need to redefine the
window.open = cordova.InAppBrowser.open;
It is better to save all assets for mobile application in the app bundle.
You can download the latest compiled widget and place it inside your
www folder, for example in the
The minimal widget version which properly works with Cordova is 2.5.7.
Widget Inclusion and Options
You can use relative paths to the widget in the script tag:
<script charset="utf-8" src="js/uploadcare-widget/uploadcare.full.js"></script>
After that, you need to set the following options:
UPLOADCARE_PUBLIC_KEY = 'demopublickey'; UPLOADCARE_SCRIPT_BASE = 'js/uploadcare-widget/'; UPLOADCARE_PASS_WINDOW_OPEN = true;
The first line is the public key, the second line is the path to widget assets, the third is a line for authentication handling for social networks and cloud storages.
Content Security Policy
Most of Cordova applications use content security policy to restrict access to unwanted resources. There is a minimal set of rules needed for the widget:
<meta http-equiv="Content-Security-Policy" content=" default-src 'self'; style-src 'unsafe-inline'; frame-src gap: https://social.uploadcare.com; img-src 'self' data: https://ucarecdn.com/; connect-src https://upload.uploadcare.com ws://ws.pusherapp.com; ">
Or just in one default-src:
<meta http-equiv="Content-Security-Policy" content=" default-src 'self' gap: data: 'unsafe-inline' https://ucarecdn.com/ https://social.uploadcare.com https://upload.uploadcare.com ws://ws.pusherapp.com; ">