JavaScript API Settings

Settings


Overview

Kiosk Pro includes a JavaScript API that allows your HTML page to interact with the iOS operating system and external peripherals in ways that would not otherwise be possible. 

To use the JavaScript API, you must instruct the app how and when to make the API calls available.  See Access JavaScript API for more details.  API calls are only available on pages loaded in the main browser window and can not be run from within an iframe. 

Below we've put together a high-level overview of the things you can do through our JavaScript API. Visit our comparison table to see which version of Kiosk Pro includes the API calls you are interested in or click through a section below to see implementation details, documentation, and sample code for that portion of the API.  

Access API

This portion of our JavaScript API allows you to access information about the device - specifically, to check if the JavaScript API is available to be called, to control your content based on the device’s orientation, to access the location coordinates of your device, and to access the Unique ID set in Kiosk Pro settings.

Capture API

Our Capture APIs allow you to save form data, take a photo or video with the device's native camera, and capture screenshots. All information is stored locally on the on the device in the Kiosk Pro Documents folder.

Using these APIs, you can run a survey or sign-up form in an area with poor or non-existent WiFi and/or cellular data connection and then retrieve the data later. The resulting data and/or files can be pulled from the iPad through a local sync directly with iTunes, or a remote sync through our Dropbox integration.

Display API

Our Display APIs allow you to share content full-screen on a connected external monitor or display, using the iPad as the controller.

Print API

Our Print APIs allow you more control over you how you print content from Kiosk Pro, including the ability to print to Star Micronics and Custom America thermal printers and AirPrint-enabled printers.

Scan API

Our Scanning APIs allow you to scan barcodes and QR codes using the device’s native cameras, an Aila scanner, or if you don't need visitor access to the on-screen keyboard, through an external Bluetooth scanner.

Swipe API

Our Swipe APIs allow you to accept magnetic stripe card swipes through a variety of card readers. If you are based in the US, this API also allows you to send fully-encrypted credit card swipes to MercuryPay for secure PCI-compliant credit card processing.

Trigger API

Our Trigger APIs allow you to trigger specific kiosk functions (like the Idle Time Limit) through custom JavaScript calls.


Access JavaScript API

This setting gives you more control over where and when these JavaScript functions are loaded.

Options:

  • By Import (Available Online & Offline) - default for Enterprise
  • By Injection (Available Offline Only)
  • Never - default for Basic & Plus

By Import (Available Online & Offline)

The recommended setting if you are using the JavaScript API, accessing the API by import allows you the ability to import the hooks through an external JavaScript file, 'kiosk_functions.js', that you reference in your page.

This has the advantage of ensuring that all hooks are loaded and ready to go when the window.onload call is triggered, which can increase reliability and simplify coding of functions that are called automatically on page load. It also means that you can just include these functions on pages where they are being used, which should speed loading of other pages.

To use this method, you will need to include 'kiosk_functions.js', referencing it as an external script in each page prior to any other external .js files or scripts that rely on these functions. To generate the latest version of 'kiosk_functions.js' compatible with the version of the app you are currently running, go to the 'Generate API Functions File' setting.

By Injection (Available Offline Only)

Accessing the JavaScript API by injection allows the app to automatically load API functions into each page as it is run. Due to Apple's rules around security and the use of JavaScript, these functions are only enabled by the app if the device is offline.

This is also the only option if you do not have direct access to add the 'kiosk_functions.js' file to each page and need access to these functions.

As our injection model is not able to provide the ability to inject hooks instantaneously into the current HTML-page, there may be a delay between window.onload trigger and the availability of these JavaScript functions. To find out exactly when the hooks are available, you have two options:

  • Listening for JavaScript callback: kp_Hooks_DidInject(). This will be called when all hooks finish injecting.
  • Check global JavaScript variable: kioskpro_hooks_available. If this variable is defined and equal to 1, then hooks are available.

Our Availability API checks if the API is available before trying to call other API functions. Documentation  is available here.

Never

This setting gives you the option of turning off our JavaScript API. None of the custom functions will be loaded or available to your pages at any time. This option may increase page loading speed so if you are not using the API, it's the best choice.


Generate API Functions File

This setting allows you to generate a new copy of the 'kiosk_functions.js' file based on the current version of the app. This file is required when accessing the JavaScript API by import.

To generate the file, tap 'Create kiosk_functions.js' in the top right of the panel. The file will be created and stored in the Kiosk Pro Documents folder.  

If your project is stored locally on the device, you can leave the file in the Documents folder and reference it with a relative URL from that location. 

If your project is hosted online, you'll need to pull the file from the Documents folder (instructions on how to transfer files to and from the device  here) and host it with the other files on your server.  (For security reasons, Apple doesn't make it possible for remotely stored webpages to access locally stored files or other assets.)

Still stuck? How can we help? How can we help?