API: Check Battery Status
This set of JavaScript API calls allow you to check the current status of the battery and can notify your content when charging status or battery levels change.
Requirements
- Integration of our JavaScript API into your webpage
- Sample code to run within the app and download for integration into your own project is available here.
- Best practices for working with the JavaScript API are available here.
- App Settings
- Content > JavaScript API > Access JavaScript API = By Import
Triggers via API Functions
Request Battery Status & Level
This function returns a callback detailing the current charging status of the device and the battery level.
Format | kp_Battery_requestInfo(callback); |
Parameters | callback - [string] the name of the callback to be triggered after the function has been executed |
Callback format | callback(batteryStatus, batteryLevel); |
Callback return values |
|
Notifications via API Callbacks
On Battery Status Change
This callback is triggered when the battery status has changed. For example, when the device is plugged into AC power.
Format | kp_Battery_statusDidChange(batteryStatus); |
Return values | batteryStatus - [integer] the current charging status of the device. Possible options include:
|
On Battery Level Change
This callback is triggered when the battery level has changed.
Format | kp_Battery_levelDidChange(batteryLevel); |
Return values | batteryLevel - [float] current battery level of the device. Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged). If battery monitoring is not enabled or cannot be determined, the value of this property is –1.0. |
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.
- To run sample code, set the app's homepage to kioskgroup.com/battery-api
- To download a .zip of sample code, click here.
Change Log
- Added in version 9.2