Access API: API Availability

Functions

App-Defined Variables

Related Settings

The custom JavaScript functions Kiosk Pro uses in its JavaScript API must be loaded before they can be called by your code. If you are accessing the JavaScript API by Import (as recommended), all functions will be loaded into the page prior to the ‘onload’ event and will be available at any time.

If you choose to access the JavaScript API by Injection, it may not be fully loaded when the ‘onload’ event is triggered. In this case, we recommend using these functions to determine when it is safe for your code to call an API function.

Requirements

  • Access JavaScript API
    • By Injection - only works offline, may not be available 'onload' event.

Note: API Availability functions are not available when the JavaScript API is accessed by Import. If you are accessing API functions by Import, they will always be available when the window.onload event triggers, so these functions are not needed or triggered in that mode.

Sample Code

This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.  
Since this API is only used by Injection (see Requirements above), this sample code cannot be run online and must be downloaded, unzipped, and stored locally in Kiosk Pro's documents folder.

Download Sample Code


kp_Vars_DidInject

This is a callback triggered by the app when all app-defined variables in the JavaScript API have been successfully loaded and are available for use.

Format
kp_Vars_DidInject(callback);
		
Parameters callback = callback name as string
Callback format
callback();
		

This callback does not return a specific value, but instead can be used to trigger other events that rely on the JavaScript API being available. This is done by defining this callback function in your code and placing a call within it.

For example, this call is used in the code sample showing how to pull the Unique iPad ID when the API is accessed by injection. In this example, the function is defined and then used to trigger a page update when the API variables are available through the inclusion of the 'updatePage()' function within 'kp_Vars_DidInject()'.


kp_Hooks_DidInject

This callback is triggered by the app when all functions and callbacks that make up the JavaScript API have been successfully loaded and are available for use.

Format
kp_Hooks_DidInject(callback);
		
Parameters callback = callback name as string
Status Returns no specific value, but can be used to trigger other events that rely on the JavaScript API being available by defining this callback function in your code and placing a call within it.

window.kioskpro_hooks_available

This variable defines whether the full JavaScript API has been loaded successfully.

Format
window.kioskpro_hooks_available
		
Possible Values
  • 1 = JavaScript API has loaded and is now available.
  • undefined = JavaScript API is not available.

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