Basic Cordova setup

Cordova Requirements

You need to install an inappbrowser plugin.

cordova plugin add cordova-plugin-inappbrowser

For future versions of the plugin, you need to redefine the method. =;

File Layout

It is better to save all assets for a mobile application in the app bundle.
You can download the latest compiled widget and place it inside your www folder, for example in the www/js/uploadcare-widget folder.

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:

After that, you need to set the following options:

UPLOADCARE_PUBLIC_KEY = 'demopublickey';
UPLOADCARE_SCRIPT_BASE = 'js/uploadcare-widget/';

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:;
    img-src 'self' data:;
    connect-src ws://;

Or just in one default-src:

<meta http-equiv="Content-Security-Policy" content="
    default-src 'self' gap: data: 'unsafe-inline' ws://;