Apache Cordova integration

One of the used frameworks integrated with DecSoft App Builder is Apache Cordova. This framework is well integrated in DecSoft App Builder in various ways for your convenience. Continue reading this help topic to see how Apache Cordova is integrated in DecSoft App Builder.

It's out of the scope of this help to explain how to install Apache Cordova, for example, to be ready to compile APKs in Microsoft Windows or IPA files in Apple Mac OS. Please, refer to the official Apache Cordova supported platforms documentation for more information about how to install Apache Cordova in your system.

Apache Cordova - Config file

DecSoft App Builder creates the right Apache Cordova configuration file for your app, based in Apache Cordova related options that you can set. One of these options are the Extra XML one, which allows to add optional stuff to the Apache Cordova configuration file.

Apache Cordova - Platforms icons

When you check the "Create a Cordova config file" from the Apache Cordova General app options, the next time that the app is compiled, DecSoft App Builder creates several icons (based in the app icon that you can set in the app Interface options) for all the supported platforms. These icons are well referred then in the Apache Cordova configuration file, in order to be used by the platforms in which our app was running.

You can additionally set "adaptative icons" for the Android platform. DecSoft App Builder take these icons (if provided) also to generate the appropriate adaptative icons.

Apache Cordova - Splash screens

When you check the "Create a Cordova config file" from the Apache Cordova General app options, the next time that the app is compiled, DecSoft App Builder creates several splash screens (based in the app splash screen that you can set in the app Apache Cordova Splashs options) for all the supported platforms. These splash screens are well referred then in the Apache Cordova configuration file, in order to be used by the platforms in which our app was running.

Apache Cordova - Batch files

When you check the "Create a Cordova config file" from the Apache Cordova General app options, and then check one or more of the Batch & Shell platforms, the next time that the app is compiled, DecSoft App Builder creates the right batch files for Microsoft Windows.

DecSoft App Builder creates various batch files per platform. Take a look at the below tables, which refers the batch files to be executed in Microsoft Windows:

Batch files for the Android platform

Batch file Description
cordova_android_debug.bat Execute this file to get a debug APK of the app. This debug release can be then copied to a device in order to debug it.
cordova_android_run.bat Connect an Android device to your computer and then execute this file in order to get a debug release APK of the app launched in your device to be debugged. This is probably the best way to try the apps in the Android platform. If no connected devices are found, the configured emulator is used instead.
cordova_android_release.bat Execute this file to get a release APK of the app. This release can be then copied to a device or deployed in the Play Store or any other Android store.
cordova_android_simulate.bat Execute this file to get a debug the app in the Apache Cordova simulator software.

Batch files for the Microsoft Windows platform

Batch file Description
cordova_electron_debug.bat Execute this file to get a debug EXE file of the app in order to be debugged.
cordova_electron_release.bat Execute this file to get a release EXE file of the app in order to be deployed.
cordova_electron_run.bat Execute this file to get a preview (no build) of the app in order to be debugged.

Batch files for the Apple iOS platform in Microsoft Windows

Batch file Description
cordova_ios.bat Execute this file to get an XCode project files to be opened and compiled using an Apple Mac OS computer. Unfortunately it's not possible to create IPA files of the app from Microsoft Windows, so this file creates the right XCode project files only.

Apache Cordova - Shell files

When you check the "Create a Cordova config file" from the Apache Cordova General app options, and then check one or more of the Batch & Shell platforms, the next time that the app is compiled, DecSoft App Builder creates the right shell files for Apple Mac OS.

DecSoft App Builder creates various shell files per platform. Take a look at the below tables, which refers the shell files to be executed in Apple Mac OS:

Shell files for the Apple iOS platform

Shell file Description
cordova_ios_debug.sh Execute this shell file from your Apple Mac OS computer to get an XCode project files ready to be opened, compiled and debugged in some device or emulator.
cordova_ios_release.sh Execute this shell file from your Apple Mac OS computer to get an XCode project files ready to be opened, compiled and archived, to get the app IPA files to be deployed in the Apple Store or in another possible way.

Shell files for the Apple Mac OS platform

Shell file Description
cordova_electron_debug.sh Execute this shell file from your Apple Mac OS computer to get a debug compilation of the app for the Apple Mac OS platform using Cordova Electron.
cordova_electron_release.sh Execute this shell file from your Apple Mac OS computer to get a release compilation of the app for the Apple Mac OS platform using Cordova Electron.
cordova_electron_run.sh Execute this shell file from your Apple Mac OS computer to get a debug compilation of the app and then launch it using Cordova Electron.

Apache Cordova - JSON files

DecSoft App Builder generates for you several Apache Cordova related JSON files. For example, when you want to sign your Android apps, sign your Apple iOS apps and sign your Microsoft Windows (Electron) apps, the right JSON files with the signing information are generated by DecSoft App Builder, so can be used when compile the app using Apache Cordova.

Apache Cordova - plugins

There are hundreds of useful Apache Cordova plugins ready to be used in your app when needed. Every Apache Cordova plugin exposes a JavaScript API in form of JavaScript objects and methods ready to be called. We can use these plugins to get information about the user device, to capture audio and video and many more things.

DecSoft App Builder integrates "out of the box" all the official Apache Cordova plugins. You can use these plugins just by checking them in the app options. Doing that the selected plugins are included in the generated Batch files and Shell files, in order to be installed for your app.

By checking one of the available Apache Cordova plugins from the app options, the IDE code editor offers to you the available plugin variables and methods, ready to be used, as you can see in the below animated GIF image:

There are sample apps for all the Apache Cordova plugins included "out of the box" in DecSoft App Builder. Take a look at them! All of samples names starts by "Cordova*", for example, "CordovaCamera", is the sample app for the Apache Cordova Camera plugin.

Available Apache Cordova plugins

Below you can see refer all the "out of the box" Apache Cordova plugins integrated in DecSoft App Builder, as well the JavaScript API that these plugins provides to you.

Apache Cordova File plugin

The Apache Cordova File plugin offers to you the ability to access the user device files and manipulate it. DecSoft App Builder, based in this plugin, put available the below JavaScript variables and methods.

Variables
Methods
cordova.file

This is the File object provided by Apache Cordova, and, among other stuff, stores the root directories in which we can place directories and files from our apps. You must use one of this root directories along other methods in this plugin.

Name Type Description
applicationDirectory String Read-only directory where the application is installed. (iOS, Android, BlackBerry 10, OSX, windows).
applicationStorageDirectory String Root directory of the application's sandbox; on iOS & windows this location is read-only (but specific subdirectories [like /Documents on iOS or /localState on windows] are read-write). All data contained within is private to the app. (iOS, Android, BlackBerry 10, OSX).
dataDirectory String Persistent and private data storage within the application's sandbox using internal memory (on Android, if you need to use external memory, use .externalDataDirectory). On iOS, this directory is not synced with iCloud (use .syncedDataDirectory). (iOS, Android, BlackBerry 10, Windows).
cacheDirectory String Directory for cached data files or any files that your app can re-create easily. The OS may delete these files when the device runs low on storage, nevertheless, apps should not rely on the OS to delete files in here. (iOS, Android, BlackBerry 10, OSX, Windows).
externalApplicationStorageDirectory String Application space on external storage. (Android).
externalDataDirectory String Where to put app-specific data files on external storage. (Android).
externalCacheDirectory String Application cache on external storage. (Android).
externalRootDirectory String External storage (SD card) root. (Android, BlackBerry 10).
tempDirectory String Temp directory that the OS can clear at will. Do not rely on the OS to clear this directory; your app should always remove files as applicable. (iOS, OSX, Windows).
syncedDataDirectory String Holds app-specific files that should be synced (e.g. to iCloud). (iOS, Windows).
documentsDirectory String Files private to the app, but that are meaningful to other application (e.g. Office files). Note that for OSX this is the user's ~/Documents directory. (iOS, OSX).
sharedDirectory String Files globally available to all applications (BlackBerry 10).
app.cordova.file.createDir()

You can use this plugin method create a new directory. This method admits the below arguments:

Name Type Description
rootDir String The root directory in which you want to create a directory. The root directory can be one of the available "cordova.file.*" values.
dirName String The name of the directory that you want to create.
successCallback Function You can set here a JavaScript function to be called when the directory has been successfully created.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while create the directory. This function receives an "error" variable with an error object.
app.cordova.file.dirExists()

You can use this plugin method to check if a directory exists or not. This method admits the below arguments:

Name Type Description
dirPath String The directory path that you want to check.
successCallback Function You must use a success callback function here. This function receive a boolean argument which is "true" if the directory exists and "false" when not.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while check the directory. This function receives an "error" variable with an error object.
app.cordova.file.removeDir()

You can use this plugin method to remove the specified directory recursively. This method admits the below arguments:

Name Type Description
dirPath String The directory path that you want to remove.
successCallback Function You can place a callback function which is executed if the directory has been successfully removed.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while remove the directory. This function receives an "error" variable with an error object.
app.cordova.file.createFile()

You can use this plugin method create a new file. Sometimes you need to create a file, for example, if you plain to use the Media plugin. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which you want to create the file.
fileName String The file name that you want to create, for example, "My new file.txt".
successCallback Function You can set here a JavaScript function to be called when the file has been successfully created. This function callback receives the created file URL, ready to be used, for example, with the Media plugin.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while create the file. This function receives an "error" variable with an error object.
app.cordova.file.fileExists()

You can use this plugin method to check if the specified file exists.

Name Type Description
filePath String The file path that you want to check.
successCallback Function You must use a success callback function here. This function receive a boolean argument which is "true" if the file exists and "false" when not.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while check the file. This function receives an "error" variable with an error object.
app.cordova.file.removeFile()

You can use this plugin method to remove the specified file. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which the file resides.
fileName String The file name to be removed.
successCallback Function You can place a callback function which is executed if the file has been successfully removed.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while remove the file. This function receives an "error" variable with an error object.
app.cordova.file.writeFile()

You can use this plugin method to write an arbitrary file type in the user's device. This method can be useful, for example, to write / save a downloaded file using the Http control. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which the file must be writed.
fileName String The file name that you want to write, for example, "myFile.png".
fileType String The MIME file type that you want to use, for example, "image/png".
contents String The content that you want to write into the file.
successCallback Function You can set here an optional JavaScript function to be called when the file has been successfully written.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while write the file. This function receives an "error" variable with an error object.
app.cordova.file.writeTextFile()

You can use this plugin method to easily write a text file in the user device. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which the file must be placed.
fileName String The file name that you want to write, for example, "myFile.txt" or "myFile.json".
contents String The text content that you want to write into the file. Can be just plain text but also a serialized JSON object, for example.
successCallback Function You can set here an optional JavaScript function to be called when the file has been successfully written.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while write the file. This function receives an "error" variable with an error object.
app.cordova.file.appendTextFile()

You can use this plugin method to easily append text into a text file in the user device. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which the text file is placed or in which must be created if not exists.
fileName String The file name that you want to append text, for example, "myFile.txt" or "myFile.json".
contents String The text content that you want to append into the file. Can just plain text but also a serialized JSON object.
successCallback Function You can set here an optional JavaScript function to be called when the file has been successfully appended.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while append text into the file. This function receives an "error" variable with an error object.
app.cordova.file.readTextFile()

You can use this plugin method to easily read the contents of an existing text file. This method admits the below arguments:

Name Type Description
dirPath String The directory path in which the file resides.
fileName String The file name that you want to read, for example, "myFile.txt" or "myFile.json".
successCallback Function You must set here a JavaScript function which is called once the file has readed. This function receive the file contents in their unique argument.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while read the text file. This function receives an "error" variable with an error object.
app.cordova.file.getFileBlobFromFileUrl()

You can use this plugin method to get a file blob (ready to be uploaded to the app server, for example) based in a file URI. The Camera plugin, for example, give us the file URI of a captured image. We can use this file URI directly, to show the image in the app, and, also can convert that file URI into a file blob, in order to be uploaded to the app server.

Name Type Description
fileUrl String The file URL to be returned as a blob.
successCallback Function You must set here a JavaScript function which is called once the file blob is ready. This function receive the file blob in their unique argument.
errorCallback Function You can set here an optional JavaScript function to be called if some error occur while prepare the file blob. This function receives an "error" variable with an error object.
There is a CordovaFile sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!
app.cordova.file.wkWebViewConvertFilePath()

You can use this plugin method (only for iOS) in order to convert a file URL (file://) to an appropriate URL to be used in Image, Audio Player, Video Player, controls, etc. The method returns the converted URL ready to use.

Name Type Description
fileUrl String The file URL to be converted.
There is a CordovaFile sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Media plugin

The Apache Cordova Media plugin allows to record an audio without the need of any external app, like the Media capture use.

Methods
app.cordova.media.startRecord()

Use this plugin method to start the recording of an audio. Note that this plugin method requires to create a file first, which you must do by using the app.cordova.file.createFile() method. In order to use this plugin, you must also check the "File plugin" checkbox in the app's options. This plugin method returns a media object instance, that you must use later to stop the recording (see below).

Name Type Description
fileUrl String A previously created file URL in order to store the recorded audio.
successCallback Function This function callback is executed if everything is fine, once you call to the app.cordova.media.stopRecord() method.
errorCallback Function You can set an optional function callback to be executed if an error occur while the recording. This function receives an "error" variable with an error object.

If you want to upload the recorded audio to your app server, you can do it by using the app.cordova.file.getFileBlobFromFileUrl() method.

app.cordova.media.stopRecord()

Use this method to stop a previously started audio recording with the app.cordova.media.startRecord() method. This method requires the below arguments:

Name Type Description
mediaInstance object You must specify here a media object instance, which has been previously returned by the app.cordova.media.startRecord() method.
There is a CordovaMedia sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Device plugin

The Apache Cordova Device plugin provides to you information about the device in which your app is running. This plugin put available the below JavaScript methods to retrieve the device information.

Methods
app.cordova.device.model()

Use this plugin method to retrieve the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.

app.cordova.device.platform()

Use this plugin method to retrieve the device's operating system name.

app.cordova.device.uuid()

Use this plugin method to retrieve the device's Universally Unique Identifier (UUID).

app.cordova.device.version()

Use this plugin method to retrieve the device's operating system version.

app.cordova.device.manufacturer()

Use this plugin method to retrieve the device's manufacturer.

app.cordova.device.isVirtual()

Use this plugin method to retrieve the device is running on a simulator.

app.cordova.device.serial()

Use this plugin method to retrieve the device hardware serial number.

There is a CordovaDevice sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Dialogs plugin

You can use the Apache Cordova plugins in order to show to the user customizable natives dialogs and also alert it with a device's "beep". Note that all the methods provided by this Apache Cordova plugin fallback in the native "alert", "confirm" and "prompt" JavaScript functions, so this plugin can be used also in non Apache Cordova platforms. For the "beep" method this plugin fallback to the app.beep() app method. This is a very easy to use and useful plugin that offers to you the below methods ready to be used:

Methods
app.cordova.dialogs.alert()

Use this plugin method to show to the user a customizable native alert dialog. This method admits the below arguments:

Name Type Description
message String The message to the user to be shown in the alert dialog.
title String Set an optional title for the alert dialog. The default title is "Alert".
dismissCallback Function Set an optional JavaScript function to be called when the user dismiss the alert dialog.
buttonLabel String Set an optional label for the alert dialog button. The default title is "OK".
app.cordova.dialogs.confirm()

Use this plugin method to show to the user a customizable native confirmation dialog. This method admits the below arguments:

Name Type Description
message String The message to the user to be shown in the confirmation dialog.
title String Set an optional title for the confirmation dialog. The default title is "Confirm".
confirmCallback Function Set a JavaScript function to be called when the user dismiss or press one of the available dialog buttons (see below). This function receives one argument with the index of the pressed button, or "0" (zero) if the user dismiss the dialog without press any button.
buttonLabels Array of strings Set an optional labels for the dialog buttons. By default the buttons are "[OK, Cancel]".
app.cordova.dialogs.prompt()

Use this plugin method to show to the user a customizable native prompt dialog. This method admits the below arguments:

Name Type Description
message String The message to the user to be shown in the prompt dialog.
title String Set an optional title for the prompt dialog. The default title is "Prompt".
promptCallback Function Set a JavaScript function in order to be called when the user press one of the available dialogs button or when dismiss the dialog without pressing any button. This function receives one object variable argument with two properties: "buttonIndex", with the pressed dialog button or "0" zero if the dialog has been dismissed without pressing any button; and the object property "input1", which stores the text entered by the user in the prompt dialog.
buttonLabels Array of strings Set an optional labels for the dialog buttons. By default the buttons are "[OK, Cancel]".
defaultText String Set the default text to be shown in the prompt dialog input box when the dialog is show.
app.cordova.dialogs.beep()

Use this plugin method to play a device "beep" the specified number of times. Note that some devices like Android can play the established notification tone instead of a classical beep. This method admits the below arguments:

Name Type Description
times Number Specify the number of times that you want to play the beep sound.
There is a CordovaDialogs sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Vibration plugin

The Apache Cordova Vibration plugin allows to perform a vibration or a vibration pattern in the user device, as well to cancel a performing vibration. This plugin provides to you the below methods:

Methods
app.cordova.vibration.vibrate()

Use this plugin method to perform a vibration in the user device during the specified milliseconds.

Name Type Description
milliseconds Number Specifies the number of milliseconds to vibrate the device.
app.cordova.vibration.vibratePattern()

Use this plugin method to perform a vibration in the user device using the specified pattern.

Name Type Description
pattern Array of numbers A sequence of numbers to be used as the pattern for the vibration (see an example below).
app.cordova.vibration.cancel()

Use this plugin method to cancel a performing vibration or vibration pattern.

There is a CordovaVibration sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Camera plugin

The Apache Cordova Camera plugin allows to get a picture from the user device, directly taken from the device camera or picked from the device photo album. We can get the taken image URI, in order to be show in the app. We can also get the Base64 string representation of the taken image, and, with the help of the Apache Cordova File plugin, we can get a blob object from the taken image, ready to be uploaded to the app server, for example. This plugin provides to you the below variables and methods:

Variables
Methods
app.cordova.camera.sourceType

This is an object variable that stores the possible source type value to be used in the configuration variable to be passed to the app.cordova.camera.getPicture() method. This object variable provide the below properties / values to be used:

Name Type Description
PHOTOLIBRARY Number Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android).
CAMERA Number Take picture from camera.
SAVEDPHOTOALBUM Number Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android) .
app.cordova.camera.destinationType

This is an object variable that stores the possible destination type value to be used in the configuration variable to be passed to the app.cordova.camera.getPicture() method. This object variable provide the below properties / values to be used:

Name Type Description
DATA_URL Number Return base64 encoded string. DATAURL can be very memory intensive and cause app crashes or out of memory errors. Use FILEURI or NATIVE_URI if possible.
FILE_URI Number Return file uri (content://media/external/images/media/2 for Android).
app.cordova.camera.encodingType

This is an object variable that stores the possible encoding type value to be used in the configuration variable to be passed to the app.cordova.camera.getPicture() method. This object variable provide the below properties / values to be used:

Name Type Description
JPEG Number Return JPEG encoded image.
PNG Number Return PNG encoded image.
app.cordova.camera.mediaType

This is an object variable that stores the possible media type value to be used in the configuration variable to be passed to the app.cordova.camera.getPicture() method. This object variable provide the below properties / values to be used:

Name Type Description
PICTURE Number Allow selection of still pictures only. Will return format specified via DestinationType.
VIDEO Number Allow selection of video only, ONLY RETURNS URL.
ALLMEDIA Number Allow selection from all media types.
app.cordova.camera.direction

This is an object variable that stores the possible direction value to be used in the configuration variable to be passed to the app.cordova.camera.getPicture() method. This object variable provide the below properties / values to be used:

Name Type Description
BACK Number Use the back-facing camera.
FRONT Number Use the front-facing camera.
app.cordova.camera.config

This is an object variable that stores the default configuration object to be used when call to the app.cordova.camera.getPicture() method. You can modify a bit this variable and then pass to the referred method, or creates a similar object variable, in order to be used in that method.

Name Type Description
quality Number Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.).
destinationType Number Choose the format of the return value. One of the "app.cordova.camera.destinationType.*" values.
sourceType Number Set the source of the picture. One of the "app.cordova.camera.sourceType.*" values.
allowEdit Boolean Allow simple editing of image before selection.
encodingType Number Choose the returned image file's encoding.
targetWidth Number Width in pixels to scale image. Must be used with targetHeight. Aspect ratio remains constant.
targetHeight Number Height in pixels to scale image. Must be used with targetWidth. Aspect ratio remains constant.
mediaType Number Set the type of media to select from. Only works when "sourceType" is "PHOTOLIBRARY" or "SAVEDPHOTOALBUM".
correctOrientation Boolean Rotate the image to correct for the orientation of the device during capture.
saveToPhotoAlbum Boolean Save the image to the photo album on the device after capture.
cameraDirection Number Choose the camera to use (front- or back-facing).
app.cordova.camera.getPicture()

Use this plugin method to take a picture from the user device, taking it from the device's camera or the device's photo album. This plugin admits the below arguments:

Name Type Description
successCallback Function Set a JavaScript function to be called when the picture has been successfully taken. This function receives one argument with the returned picture. The returned type depend on the "destinationType" configuration variable and can be a file URI and also the Base64 representation of the taken picture.
errorCallback Number Set a JavaScript function to be called if some error occur while the picture is taken. The function receives one argument with information about the error. Note that this function is also called if the user just cancel the selection of the picture.
config Object An object that set the configuration for the method. You can use here the default configuration variable, modify a bit that variable, or just pass a similar variable to the method.
There is a CordovaCamera sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!
app.cordova.camera.wkWebViewConvertFilePath()

You can use this plugin method (only for iOS) in order to convert a file URL (file://) to an appropriate URL to be used in Image, Audio Player, Video Player, controls, etc. The method returns the converted URL ready to use.

Name Type Description
fileUrl String The file URL to be converted.
There is a CordovaCamera sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova InAppBrowser plugin

The Apache Cordova InAppBrowser plugin provides to you a way to show contents in an external but controlable browser window. Below you can see the JavaScript method who this plugin provides to you, as well as usage sample code.

Methods
app.cordova.inAppBrowser.open()

Use this plugin method to show contents on an external browser window. This method admits the below arguments:

Name Type Description
url String The URL to load. Call encodeURI() on this if the URL contains Unicode characters.
target String The URL to load. Call encodeURI() on this if the URL contains Unicode characters. This argument can be one of these values:
  • _blank: Opens in the "InAppBrowser" browser.
  • _system: Opens in the system's web browser.
options String

Specify the options to be used. Default value is: "location=yes". This argument can be

The options string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive.

All platforms support:

  • location: Set to yes or no to turn the InAppBrowser's location bar on or off.

The Android platform supports these additional options:

  • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
  • beforeload: set to enable the beforeload event to modify which pages are actually loaded in the browser. Accepted values are get to intercept only GET requests, post to intercept on POST requests or yes to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).
  • clearcache: set to yes to have the browser's cookie cache cleared before the new window is opened
  • clearsessioncache: set to yes to have the session cookie cache cleared before the new window is opened
  • closebuttoncaption: set to a string to use as the close button's caption instead of a X. Note that you need to localize this value yourself.
  • closebuttoncolor: set to a valid hex color string, for example: #00ff00, and it will change the close button color from default, regardless of being a text or default X. Only has effect if user has location set to yes.
  • footer: set to yes to show a close button in the footer similar to the iOS Done button. The close button will appear the same as for the header hence use closebuttoncaption and closebuttoncolor to set its properties.
  • footercolor: set to a valid hex color string, for example #00ff00 or #CC00ff00 (#aarrggbb) , and it will change the footer color from default. Only has effect if user has footer set to yes.
  • hardwareback: set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history. If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser.
  • hidenavigationbuttons: set to yes to hide the navigation buttons on the location toolbar, only has effect if user has location set to yes. The default value is no.
  • hideurlbar: set to yes to hide the url bar on the location toolbar, only has effect if user has location set to yes. The default value is no.
  • navigationbuttoncolor: set to a valid hex color string, for example: #00ff00, and it will change the color of both navigation buttons from default. Only has effect if user has location set to yes and not hidenavigationbuttons set to yes.
  • toolbarcolor: set to a valid hex color string, for example: #00ff00, and it will change the color the toolbar from default. Only has effect if user has location set to yes.
  • lefttoright: Set to yes to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the left and close button to the right.
  • zoom: set to yes to show Android browser's zoom controls, set to no to hide them. Default value is yes.
  • mediaPlaybackRequiresUserAction: Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no).
  • shouldPauseOnSuspend: Set to yes to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid some Google Play issues).
  • useWideViewPort: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is no, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is yes and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to yes).

The iOS platform supports these additional options:

  • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
  • beforeload: set to enable the beforeload event to modify which pages are actually loaded in the browser. Accepted values are get to intercept only GET requests, post to intercept on POST requests or yes to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).
  • clearcache: set to yes to have the browser's cookie cache cleared before the new window is opened
  • clearsessioncache: set to yes to have the session cookie cache cleared before the new window is opened. For WKWebView, requires iOS 11+ on target device.
  • cleardata: set to yes to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened
  • closebuttoncolor: set as a valid hex color string, for example: #00ff00, to change from the default Done button's color. Only applicable if toolbar is not disabled.
  • closebuttoncaption: set to a string to use as the Done button's caption. Note that you need to localize this value yourself.
  • disallowoverscroll: Set to yes or no (default is no). Turns on/off the UIWebViewBounce property.
  • hidenavigationbuttons: set to yes or no to turn the toolbar navigation buttons on or off (defaults to no). Only applicable if toolbar is not disabled.
  • navigationbuttoncolor: set as a valid hex color string, for example: #00ff00, to change from the default color. Only applicable if navigation buttons are visible.
  • toolbar: set to yes or no to turn the toolbar on or off for the InAppBrowser (defaults to yes)
  • toolbarcolor: set as a valid hex color string, for example: #00ff00, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
  • toolbartranslucent: set to yes or no to make the toolbar translucent(semi-transparent) (defaults to yes). Only applicable if toolbar is not disabled.
  • lefttoright: Set to yes to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.
  • enableViewportScale: Set to yes or no to prevent viewport scaling through a meta tag (defaults to no). Only applicable to UIWebView (usewkwebview=no) and WKWebView (usewkwebview=yes) on iOS 10+.
  • mediaPlaybackRequiresUserAction: Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no). Applicable to UIWebView (usewkwebview=no) and WKWebView (usewkwebview=yes).
  • allowInlineMediaPlayback: Set to yes or no to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's video element must also include the webkit-playsinline attribute (defaults to no). Applicable to UIWebView (usewkwebview=no) and WKWebView (usewkwebview=yes).
  • keyboardDisplayRequiresUserAction: Set to yes or no to open the keyboard when form elements receive focus via JavaScript's focus() call (defaults to yes). Only applicable to UIWebView (usewkwebview=no).
  • suppressesIncrementalRendering: Set to yes or no to wait until all new view content is received before being rendered (defaults to no). Only applicable to UIWebView (usewkwebview=no).
  • presentationstyle: Set to pagesheet, formsheet or fullscreen to set the presentation style (defaults to fullscreen).
  • transitionstyle: Set to fliphorizontal, crossdissolve or coververtical to set the transition style (defaults to coververtical).
  • toolbarposition: Set to top or bottom (default is bottom). Causes the toolbar to be at the top or bottom of the window.
  • hidespinner: Set to yes or no to change the visibility of the loading indicator (defaults to no).

The Windows platform supports these additional options:

  • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
  • hardwareback: works the same way as on Android platform.
  • fullscreen: set to yes to create the browser control without a border around it. Please note that if location=no is also specified, there will be no control presented to user to close IAB window.
There is a CordovaInAppBrowser sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Screen Orientation plugin

The Apache Cordova Screen Orientation plugin provides to you a way to change and lock the device screen orientation at runtime. You can establish the default screen orientation to be used at designtime, from the Apache Cordova Configuration options. This plugin put also available the app OrientationChange event.

Variables
Methods
app.cordova.screenOrientation.orientation

This is an object variable that stores all the possible values to be used with the app.cordova.screenOrientation.lock() method. This object variable provide the below properties / values to be used:

Name Type Description
portraitPrimary String The orientation is in the primary portrait mode.
portraitSecondary String The orientation is in the secondary portrait mode.
landscapePrimary String The orientation is in the primary landscape mode.
landscapeSecondary String The orientation is in the secondary landscape mode.
portrait String The orientation is either portrait-primary or portrait-secondary (sensor).
landscape String The orientation is either landscape-primary or landscape-secondary (sensor).
any String The screen orientation is unlocked - all orientations are supported.
app.cordova.screenOrientation.lock()

You can use this plugin method to lock the screen orientation to one of the "app.cordova.screenOrientation.orientation.*" values. This method admits the below argumens:

Name Type Description
orientation String One of the "app.cordova.screenOrientation.orientation.*" values.
app.cordova.screenOrientation.unlock()

You can use this plugin method to unlock the screen orientation.

app.cordova.screenOrientation.type()

You can use this plugin method to know the current established screen orientation. This method returns one of the "app.cordova.screenOrientation.orientation.*" values.

There is a CordovaScreenOrientation sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Battery Status plugin

The Apache Cordova Battery Status plugin provides information about the device battery level, as well to know if the device is plugged or not. This plugin provides the below app events:

App events that relies on this plugin

The Apache Cordova Battery Status plugin provides also the below variables:

Variables
app.cordova.battery.level

This variable is available in the related battery app events and stores a number which represents the percentage of the device's battery level, that can be from 0 to 100.

app.cordova.battery.isPlugged

This variable is available in the related battery app events and stores a boolean value which means that the device is plugged in ("true") or not ("false").

There is a CordovaBatteryStatus sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Geolocation plugin

The Apache Cordova Geolocation plugin provides information about the device geolocation. This plugin provides the below variables and methods:

Variables
Methods
app.cordova.geolocation.config

This is an object variable that stores the default configuration that can be used with the app.cordova.geolocation.getCurrentPosition() method and the app.cordova.geolocation.watchPosition() method. You can modify this variable or creates a similar one in order to be passed to these methods. This variable have the below properties:

Name Type Description
maximumAge Number Accept a cached position whose age is no greater than the specified time in milliseconds.
timeout Number The maximum length of time (milliseconds) that is allowed to pass from the call to the app.cordova.geolocation.getCurrentPosition() method or the app.cordova.geolocation.watchPosition() method until the corresponding "successCallback" executes. If the "successCallback" callback is not invoked within this time, the "errorCallback" callback is passed a "TIMEOUT" error code. (Note that when used in conjunction with app.cordova.geolocation.watchPosition() method, the "errorCallback" callback could be called on an interval every timeout milliseconds!).
enableHighAccuracy Boolean Provides a hint that the application needs the best possible results. By default, the device attempts to retrieve a Position using network-based methods. Setting this property to true tells the framework to use more accurate methods, such as satellite positioning.
app.cordova.geolocation.getCurrentPosition()

You can use this plugin method to get the current geolocation information of the device. This method admits the below arguments:

Name Type Description
successCallback Function

Set a JavaScript function to be called when the plugin retrieves the device geolocation information. This function receives one "position" object variable argument with the below properties:

  • position.coords.latitude: Latitude in decimal degrees. (Number)
  • position.coords.longitude: Longitude in decimal degrees. (Number)
  • position.coords.altitude: Height of the position in meters above the ellipsoid. (Number)
  • position.coords.accuracy: Accuracy level of the latitude and longitude coordinates in meters. (Number)
  • position.coords.altitudeAccuracy: Accuracy level of the altitude coordinate in meters. (Number)
  • position.coords.heading: Direction of travel, specified in degrees counting clockwise relative to the true north. (Number)
  • position.coords.speed: Current ground speed of the device, specified in meters per second. (Number)
  • position.timestamp: Creation timestamp for coords. (DOMTimeStamp)
errorCallback Function

Set a JavaScript function to be called if an error occur and . This function receives one "error" object variable argument with information about the error:

  • error.code: One of the predefined error codes listed below.. (Number)
  • error.message: error object describing the details of the error encountered. (String)
  • error.code === 1: Permission denied. Returned when users do not allow the app to retrieve position information. This is dependent on the platform.
  • error.code === 2: Position unavailable. Returned when the device is unable to retrieve a position. In general, this means the device is not connected to a network or can't get a satellite fix.
  • error.code === 3: Timeout. Returned when the device is unable to retrieve a position within the time specified by the timeout included in the app.cordova.geolocation.config variable. When used with the app.cordova.geolocation.watchPosition() method, this error could be repeatedly passed to the erorCallback callback every timeout milliseconds.
config Object

The optional configuration / options object for the method. You can use the default values or change the default of the app.cordova.geolocation.config object variable.

app.cordova.geolocation.watchPosition()

You can use this plugin method watch the device geolocation information until you call to the app.cordova.geolocation.clearWatch() method. This method support the same arguments than the app.cordova.geolocation.getCurrentPosition() method described above. This method returns a number variable that you can pass later to the app.cordova.geolocation.clearWatch() method.

app.cordova.geolocation.clearWatch()

You can use this plugin method to stop to watch for the device geolocation information started with the app.cordova.geolocation.watchPosition() method. This method admits the below arguments:

Name Type Description
watchID Number An identifier variable as is returned by the app.cordova.geolocation.watchPosition() method.
There is a CordovaGeolocation sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Network Information plugin

The Apache Cordova NetWork Information plugin provides information about the current network connection type of the device. Additionally, by using this plugin in your app the Online event and the Offline event are properly attached and can be fired accordingly when the device loss or recover the network connection.

Variables
Methods
app.cordova.network.connectionTypes

This plugin variable is an object which contains all the possible network connection values that can be returned by the app.cordova.network.getConnectionType() method.

app.cordova.network.getConnectionType()

You can use this plugin method to retrieve the current network type of the device. This method returns one of the values provided by the app.cordova.network.connectionTypes variable.

There is a CordovaNetworkInformation sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Statusbar plugin

The Apache Cordova Statusbar plugin provides to you several ways to customize the device's statusbar. You can set various statusbar related options at designtime from the Apache Cordova - Configuration options. Use the methods of this plugin to change the device's statusbar at runtime.

Methods
app.cordova.statusbar.hide()

You can use this plugin method to hide the device's statusbar at runtime. This method don't require any arguments.

app.cordova.statusbar.show()

You can use this plugin method to show the device's statusbar at runtime. This method don't require any arguments.

app.cordova.statusbar.isVisible()

You can use this plugin method to check if the device's statusbar is visible or not. This method don't require any arguments.

app.cordova.statusbar.styleDefault()

You can use this plugin method to use the default statusbar style (dark text, for light backgrounds). This method don't require any arguments.

app.cordova.statusbar.styleLightContent()

You can use this plugin method to use the light content statusbar style (light text, for dark backgrounds). This method don't require any arguments.

app.cordova.statusbar.backgroundColorByName()

You can use this plugin method to set the statusbar background color to one of the supported color names. This method admits the below arguments:

Name Type Description
colorName String This argument can be one of these color names: black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple or brown.
app.cordova.statusbar.backgroundColorByHexString()

You can use this plugin method to set the statusbar background color by using an HTML hex string color. This method admits the below arguments:

Name Type Description
colorHexStr String An HTML color to be used, for example, "#C0C0C0". Also admits short colors like: "#333".
app.cordova.statusbar.overlaysWebView()

You can use this plugin method to make the statusbar overlay or not overlay the WebView. This method admits the below arguments:

Name Type Description
overlays Boolean Set to "true" to make the statusbar overlay on top of your app. Ensure that you adjust your styling accordingly so that your app's title bar or content is not covered. Set to "false" to make the statusbar solid and not overlay your app. You can then set the style and background color to suit using the other functions.
There is a CordovaStatusbar sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!

Apache Cordova Media Capture plugin

The Apache Cordova Media Capture plugin provides to you the right methods to capture images, audio and video from the user device. Take a look below at the provided plugin methods:

Methods
app.cordova.mediaCapture.captureAudio()

You can use this plugin method to start the audio recorder application and return information about captured audio clip file.

Name Type Description
successCallback Function

Set this argument to a JavaScript function to be called when the clip audio has been taken. The function receives one object variable as an argument with information about the selected files, in this case always an array with a sole item, with information of the taken audio. Take a look at the properties availables in the the item of this function's argument:

  • name: The name of the file, without path information. (DOMString)
  • fullPath: The full path of the file, including the name. (DOMString)
  • type: The file's mime type (DOMString)
  • lastModifiedDate: The date and time when the file was last modified. (Date)
  • size: The size of the file, in bytes. (Number)
errorCallback Function

Set this argument to a JavaScript function to be called if an error occurs while capture the audio. The function receives one object variable as an argument with the error information. Below you can see the possible errors:

  • error.code === 0: The camera or microphone failed to capture image or sound.
  • error.code === 1: The camera or audio capture application is currently serving another capture request.
  • error.code === 2: Invalid use of the API.
  • error.code === 3: The user exits the camera or audio capture application before capturing anything.
  • error.code === 4: The user denied a permission required to perform the given capture request.
  • error.code === 20: The requested capture operation is not supported.
app.cordova.mediaCapture.captureVideo()

You can use this plugin method to start the video recorder application and return information about captured video clip file.

Name Type Description
successCallback Function

Set this argument to a JavaScript function to be called when the clip video has been taken. The function receives one object variable as an argument with information about the selected files, in this case always an array with a sole item, with information of the taken video. Take a look at the properties availables in the the item of this function's argument:

  • name: The name of the file, without path information. (DOMString)
  • fullPath: The full path of the file, including the name. (DOMString)
  • type: The file's mime type (DOMString)
  • lastModifiedDate: The date and time when the file was last modified. (Date)
  • size: The size of the file, in bytes. (Number)
errorCallback Function

Set this argument to a JavaScript function to be called if an error occurs while capture the video. The function receives one object variable as an argument with the error information. Below you can see the possible errors:

  • error.code === 0: The camera or microphone failed to capture image or sound.
  • error.code === 1: The camera or audio capture application is currently serving another capture request.
  • error.code === 2: Invalid use of the API.
  • error.code === 3: The user exits the camera or audio capture application before capturing anything.
  • error.code === 4: The user denied a permission required to perform the given capture request.
  • error.code === 20: The requested capture operation is not supported.
app.cordova.mediaCapture.captureImage()

You can use this plugin method to capture an image and retrieves information about captured image file. Note that you can also use the Apache Cordova Camera plugin to capture a picture from the user device.

Name Type Description
successCallback Function

Set this argument to a JavaScript function to be called when the image has been captured. The function receives one object variable as an argument with information about the selected files, in this case always an array with a sole item, with information of the captured image. Take a look at the properties availables in the the item of this function's argument:

  • name: The name of the file, without path information. (DOMString)
  • fullPath: The full path of the file, including the name. (DOMString)
  • type: The file's mime type (DOMString)
  • lastModifiedDate: The date and time when the file was last modified. (Date)
  • size: The size of the file, in bytes. (Number)
errorCallback Function

Set this argument to a JavaScript function to be called if an error occurs while capture the image. The function receives one object variable as an argument with the error information. Below you can see the possible errors:

  • error.code === 0: The camera or microphone failed to capture image or sound.
  • error.code === 1: The camera or audio capture application is currently serving another capture request.
  • error.code === 2: Invalid use of the API.
  • error.code === 3: The user exits the camera or audio capture application before capturing anything.
  • error.code === 4: The user denied a permission required to perform the given capture request.
  • error.code === 20: The requested capture operation is not supported.
There is a CordovaMediaCapture sample app included with the installation of DecSoft App Builder. Take a look to see this plugin in action!