Cordova solutions.

This page provides solutions to various Cordova-related bugs, problems, or workarounds.

Check if App is Running on Device

The following code helps determine if the app is running in a browser or on a device:

var isCordovaApp = function () {
   return (document.URL.indexOf('http://') === -1 && 
    document.URL.indexOf('https://') === -1);
// this function will return 
// 'true' - if it's running on the device
// 'false' - if it's running in the browser

resolveLocalFileSystemURL doesn't work

Solving native path of android (content://) if resolveLocalFileSystemURL doesn't work. Read more.

PDF generating plugin

IONIC example.

  1. Import the Cordova plugin to your account:
    Use the steps for importing this plugin from GitHub here.
  2. In the Ionic App builder create the scope function with the following code:
var options = {

    documentSize: 'A4',

   type: 'base64'


pdf.fromData('Hello World', options)

    .then(function(base64){alert(base64);} )   // returns base64:JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVh...

  1. Run that function on any button click event or other events in your app.