voltmx.os Namespace
The voltmx.os namespace provides functions for the Operating System API. It contains the following API elements:
Constants
The voltmx.os Namespace contains the following types of constants.
Battery State Constants
These constants specify the current state of the device battery.
Constant | Description |
---|---|
BATTERY_STATE_CHARGING | Indicates that the state of the device battery as being charged. |
BATTERY_STATE_DISCHARGING | Indicates that the state of the device battery as being discharged. |
BATTERY_STATE_FULL | Indicates that the state of the device battery charge is completely full. |
BATTERY_STATE_UNKNOWN | Indicates that the state of the device battery charge as not known. |
Example
When you query for the state of the device battery as shown in this example, any of the four available battery states is returned.
Platform Availability
- iOS
- Android
- Windows
=======
Functions
The voltmx.os namespace contains the following functions.
voltmx.os.addHiddenField
This API helps the developers to pass dynamic values when the form needs to be submitted to external sites.
Syntax
Input Parameters
Parameter | Description |
---|---|
key [String] - Mandatory | Specifies the key of the hidden field that you would like to add. |
value [String] - Mandatory | Specifies the value that corresponds to the specified key in the hidden field. |
private [String] - Optional | Specifies if the hidden field can be read using the voltmx.os.readHiddenField API. The expected values for this field are either “private” or “public”. The default value of this field id “public”. > Note: Only when this value is specified, you can read the hidden value through voltmx.os.readHiddenField API. |
Example
Return Values
None.
Platform Availability
Available only on Mobile Web.
voltmx.os.addMetaTag
This API adds a meta tag in.html header. This API result will effect only on header reload.
Syntax
Input Parameters
Parameter | Description |
---|---|
key [String] - Mandatory | Adds a meta tag in the HTML header |
value [Object] - Mandatory | Adds meta tag attributes in the.html header as key value pairs. |
Example
Return Values
This API has no return values.
Platform Availability
Applicable only on Mobile Web.
voltmx.os.createUUID
UUID (Universally Unique Identifier) is a universally unique value that can be used to identify types, interfaces, and other items. This API returns a string that contains a formatted UUID value. For example, E621E1F8-C36C-495A-93FC-0C247A3E6E5F.
Syntax
Input Parameters
None
Example
Return Type
String
Platform Availability
- Android
- iOS
voltmx.os.detectDynamicInstrumentation
This API helps your application to detect the presence of any Dynamic Instrumentation instance. Currently, this API only supports the detection of Frida server presence.
Syntax
Input Parameters
Parameter | Description |
---|---|
object[Object] -Mandatory | This is a dictionary that contains the following keys: detectedCallback [Function] - OptionalThis callback is executed when the presence of Dynamic Instrumentation is detected. If you do not specify this key, the application safely exits by default whenever it detects Dynamic Instrumentation.undetectedCallback [Function] - OptionalThis callback is executed when Dynamic Instrumentation is not detected. type [String] - Mandatory This parameter specifies the type of detection that is to be performed. You can specify any one of the following values for this parameter:fridaquickscan - Returns results quickly and can be used synchronously in JS code.fridadeepscan - Performs a deep scan to search for the presence of Frida server, and it takes about six or more seconds to return the result. For this reason, you must use the fridadeepscan option in WorkerThread. |
Example
Return Value
None
Platform Availability
- Android
voltmx.os.deviceInfo
This API allows the developers to get information about the device in which the application is launched.
You can view a video on using Device Info API here.
Syntax
Input Parameters
None
Example
Return Values
Return Value | Description |
---|---|
values[Object] | Returns a DeviceInfo object. |
Platform Availability
Available on all platforms.
voltmx.os.endSecureTransaction
This API can be invoked on an event of a widget. This API should be invoked on forms of the application where user validation is not required or cross site request forgery is not a concern.
Syntax
Input Parameters
None
Example
Return Values
None
Platform Availability
Available only on Mobile Web.
voltmx.os.freeMemory
This API provides the ability to query and fetch the system-wide memory available on the mobile device for allocation.
You can use this API to:
- Check the amount of free memory on the mobile device before you go ahead with installation of any software or applications.
- Find out the free memory on the mobile device, clear unwanted objects, and thus improve the performance of the application.
Syntax
Input Parameters
None
Example
In the following example, voltmx.os.freeMemory returns the freememory available for allocation.
Return Values
Return Value | Description |
---|---|
Free memory[Number] | The available memory for allocation is returned. The returned memory always indicates the number of bytes available. |
Platform Availability
Available on all platforms* except Windows. *Dummy implementation on Server Side Mobile Web, SPA, and DesktopWeb and returns a dummy value.
voltmx.os.getAppContext
This API allows the developers to get information about the mode in which the application is launched.
Syntax
Input Parameters
None
Example
Return Values
Return Value | Description |
---|---|
contextDetails[Object] | Returns an object with key-value pairs:launchmode:0 indicates that the application is launched in normal mode.launchmode:1 indicates that the application is launched in full screen mode. |
Platform Availability
Applicable only on Mobile Web.
voltmx.os.getBatteryLevel
Retrieves the current percentage charge level of the device battery, as an integer value.
Syntax
Input Parameters
None
Example
Return Values
Returns an integer that ranges from 0-100 (inclusive) that specifies the battery’s current charge level in percentage. For example, a return value of 30 specifies that the current charge level of the battery is 30%.
Platform Availability
- iOS
- Android
- Windows
voltmx.os.getBatteryState
Retrieves the current state of the battery.
Syntax
Input Parameters
None
Example
Return Values
Returns a constant from the Battery State Constants.
Remarks
The battery state indicates whether it is charging, discharging, and so forth.
Platform Availability
- iOS
- Android
- Windows
voltmx.os.getDeviceId
This API is deprecated. It always returns null.
voltmx.os.getDeviceCurrentOrientation
This API returns the current orientation of the device. The possible values are portrait or landscape.
Syntax
Input Parameters
None
Example
Return Values
This API returns whether the device orientation is landscape or portrait.
- constants.DEVICE_ORIENTATION_PORTRAIT
- constants.DEVICE_ORIENTATION_LANDSCAPE
Platform Availability
Available on iPhone, iPad, Windows, Android, and Desktop Web
voltmx.os.getOpenGLESVersion
This API returns the maximum OpenGLES Version supported by the device.
Depending on the value returned, you can determine if the device supports AR capabilities.
Syntax
Input Parameters
None.
Example
Return Values
Return Value | Description |
---|---|
version | Returns the Open GLES Version number. |
Platform Availability
Android
voltmx.os.hasAccelerometerSupport
This API returns whether accelerometer is supported on a device.
Syntax
Input Parameters
None.
Return Values
Return Value | Description |
---|---|
value[Boolean] | Returns whether accelerometer is supported on a device. |
Platform Availability
Applicable only on iPhone, Android, and Windows platforms.
Example
voltmx.os.hasCameraSupport
This API returns whether Camera is supported on a device.
Syntax
Input Parameters
None.
Example
Return Values
Return Value | Description |
---|---|
value[Boolean] | true: the platform supports Camera false: the platform does not support Camera |
Platform Availability
Available on all platforms* except Mobile Web. *Dummy implementation for SPA and Desktop Web that always returns False.
voltmx.os.hasGPSSupport
This API returns whether GPS is supported on a device.
Syntax
Input Parameters
None.
Example
Return Values
Return Value | Description |
---|---|
value[Boolean] | true: the platform supports GPS. false: the platform does not support GPS. |
Platform Availability
Available on all platforms except Mobile Web.
voltmx.os.hasOrientationSupport
This API returns whether Orientation is supported on a device.
You can view a video on using Display Orientation here.
Syntax
Input Parameters
None.
Example
Return Values
Return Value | Description |
---|---|
value[Boolean] | true: the platform supports orientation. false: the platform does not support orientation. |
Platform Availability
Available on all platforms except Mobile Web.
voltmx.os.hasTouchSupport
This API returns whether Touch is supported on a device.
Syntax
Input Parameters
None.
Example
Return Values
Return Value | Description |
---|---|
value[Boolean] | true: the platform supports touch. false: the platform does not support touch. |
Platform Availability
Available on all platforms except Mobile Web and Desktop Web.
voltmx.os.print
When invoked without any parameter, this API prints the entire form that is currently in view.
Syntax
Input Parameters
| Parameter | Description | | — | — | | containerID [Number] - Optional | The containerID can be a ID of any container widget that can be directly referenced from a form.
Note: If the user is typing in a text box, the typed content will not be printed. Print API can be used only after the target Form, Popup or Datagrid is rendered on the browser. Print API cannot be used in pre-show, post-show, pre and post app init or any other functionality that is run before the target Form, Popup, or Datagrid is fully rendered. When printing the form with widgets like ScrollBox, Image Strip, the print functionality prints only those widgets that are in the view or potentially occupy the available print space in portrait or landscape views.
Example
Return Values
None.
Platform Availability
Applicable only on Desktop Web.
voltmx.os.readHiddenField
This API allows the developers to read the hidden fields added by the os.addHiddenField
API.
Syntax
Input Parameters
Parameters | Description |
---|---|
key [String] - Mandatory | Specifies the key of the hidden field that you would like to read. |
Example
Return Values
Return Value | Description |
---|---|
value[String] | Returns the value that corresponds to the specified key. |
nil | nil is returned if there is no value assigned to the corresponding key. |
Platform Availability
Available only on Mobile Web.
voltmx.os.registerBatteryService
Registers for the battery monitoring service of the device operating system. The callback is delivered to the most recent registered battery service.
Note: Whenever the battery state changes or for every 1% change in the battery level, a callback to the registerBatteryService function is triggered.
Syntax
Input Parameters
Parameter | Description |
---|---|
callbackMethod | A JavaScript function that is automatically invoked when you register to the battery monitoring service of the device OS. |
Example
Return Values
None
Limitations
- The callback for the registered battery service is delivered only when the application is running; this is because, you can only receive notifications when the application is in the foreground for the iOS, Windows, and Android platforms.
- The callback to the registered battery service is delivered after every one minute duration for iOS; whereas in case of in Android and Windows, the callback is delivered for every 1% change in the battery charge.
Platform Availability
- iOS
- Android
- Windows
voltmx.os.registerSpeechRecognizer
Registers callbacks for speech recognition events.
Syntax
Input Parameters
| Parameters | Description | | — | — | | callbackTable[JSON object] - Mandatory | The callbackTable is a mandatory key-value pair, that helps you to register JavaScript callbacks, which are triggered when any speech to text recognition events occur.Following are the key-value pairs:
resultGenerated [callback]
Triggered continuously whenever a phrase is generated out of the recognized speech. Parameters for callback [JSON object]result [String] The recognized phrase of the speech recognition session.confidence [Number]The confidence level of the speech recognition result. For example, if the speech includes a word such as “weight,” the confidence level is the certainty with which the app recognizes the word as “weight” and not as “wait.”0 - High1 - Medium2 - Low3 - Rejectedstatus [Number]The status of the result. 0 - Success 1 - TopicLanguageNotSupported 2 - GrammarLanguageMismatch3 - GrammarCompilationFailure 4 - AudioQualityFailure5 - UserCanceled 6 - Unknown 7 - TimeoutExceeded8 - PauseLimitExceeded 9 - NetworkFailure10 - MicrophoneUnavailable
timeouts [JSON object]Set initial, in-session (continuous event), and end silence timeouts based on which the speech recognition session will be stopped.initialSilenceTimeout [Number] Minimum timeout value (in seconds) given to ignore the silence (no speech input) after the speech recognition session starts (that is, before the speech is recognized and text is generated). Default value is 5 seconds.autoStopSilenceTimeout [Number]Minimum timeout value (in seconds) given to ignore the silence between the event(s) that are triggered continuously (that is, during speech recognition process).endSilenceTimeout [Number]Minimum timeout value (in seconds) to ignore the silence (no speech input) after which the speech recognition should end (that is, after speech is recognized and text is generated). Default value is 150 milliseconds.
Example
Return Values
None.
Platform Availability
Available only on Windows.
voltmx.os.removeAllMetaTags
This API removes all the user defined meta tags from a.html header. This API result will effect only on header reload.
Syntax
Input Parameters
None.
Example
Return Values
None.
Platform Availability
Applicable only on Mobile Web.
voltmx.os.removeMetaTag
This API removes a specific meta tag from a.html header. This API result will effect only on header reload.
Syntax
Input Parameters
Parameters | Description |
---|---|
key [String] - Mandatory | Removes a meta tag with the specific key in.html header. |
Example
Return Values
This API has no return values.
Platform Availability
Applicable only on Mobile Web.
voltmx.os.startSecureTransaction
This API can be invoked on an event of a widget. When this API is invoked it makes all the data and subsequent transactions of the application secure. For example, the login page of an application has the following: user name field, password field, and a button. On the onclick event of the button, the user is verified and navigated to pages with sensitive information. If you want to prevent cross site request forgery or double submissions, you can invoke this API ensuring that all the subsequent transactions are secure.
Syntax
Input Parameters
Parameters | Description |
---|---|
callback [Function] - Mandatory | If there are instances where cross site request forgery is attempted, this parameter should comprise a session/request expiry function. |
scope [Integer] - Mandatory | Specifies whether this API will be valid per request or per session of the application. The possible values are as follows:0 - Request Scope: The data in the application is secure only on a per request basis.> Note: If you press the browser back button on BJS, the token is rendered invalid on the browser back request.1 - Session Scope. The data is secure for an entire user session. This is the default value. |
Example
Return Values
This API has no return values.
Remarks
Whenever os.startsecuretransaction is invoked, a krfid for that session or request is generated internally as a hidden field. The krfid is validated for each transaction/request. If the krfid is invalid, the callback function of os.startsecuretransaction API is invoked, and the request processing fails or a message appears stating that the session has expired.
Platform Availability
Available only on Mobile Web.
voltmx.os.startSpeechRecognition
Starts the speech recognition process.
Note: Speech recognition callback(s) must be registered before invoking this API. Refer voltmx.os.registerSpeechRecognizer API for more information.
Syntax
Input Parameters
Parameters | Description |
---|---|
successCallback [JS Function] - Optional | Triggered when speech recognition has started successfully. |
errorCallback [JS Function] - Optional | Triggered if there is an error while starting the speech recognition operation or if the speech recognition operation is already in progress. |
Example
Return Values
None.
Platform Availability
Available only on Windows.
voltmx.os.stopSpeechRecognition
Stops existing (already started with voltmx.os.startSpeechRecognition API) speech recognition operations.
Note: Speech recognition callback(s) must be registered before invoking this API. Refer voltmx.os.registerSpeechRecognizer API for more information.
Syntax
Input Parameters
Parameters | Descrption |
---|---|
successCallback [JS Function] - Optional | Triggered when speech recognition has stopped successfully. |
errorCallback [JS Function] - Optional | Triggered if there is an error while stopping the speech recognition operation or if there is no speech recognition operation in progress to stop. |
Example
Return Values
None.
Platform Availability
Available only on Windows.
voltmx.os.toCurrency
This API allows you to convert the given number to represent currency. At present, only USA currency is supported.
Syntax
Input Parameters
Parameters | Description |
---|---|
number[Number] - Mandatory | Specifies the number that must be converted to represent currency.If the input number is a negative number, the negative number is treated as a positive number (this is because a currency does not have any negative symbol) and the converted value is returned. |
Example
Perform a voltmx.os.toCurrency operation on the number “10000”.
Return Values
Return Value | Description |
---|---|
Currency [String] | A string with the number formatted as currency. If the input string has decimal points, the return value is truncated till two decimal points. |
Exceptions
An error is thrown if input is invalid or does not follow the expected structure.
102 - Invalid input error
Platform Availability
Available on all platforms.
voltmx.os.toNumber
This API converts the argument to a number. If the argument is already a number or a string convertible to a number, then the API returns this number; otherwise, it returns null for JavaScript.
Syntax
voltmx.os.toNumber**([argument](#argument))
Input Parameters
Parameters | Description |
---|---|
argument [String or Number] - Mandatory | The argument that must be converted to a number. |
Example
In this example, only the string which can be converted to a number returns a number otherwise it returns n.
Return Values
Return Value | Description |
---|---|
Converted Number [Number] | The input string or number that has been converted to a number and returned. |
null/nil | The argument cannot be converted to a number. |
Remarks
The input parameter must be a number or a string.
Exceptions
An error is thrown if input is invalid or does not follow the expected structure.
102 - Invalid input error
Platform Availability
Available on all platforms.
voltmx.os.unregisterBatteryService
This API stops the monitoring process of the device battery. You must call this API when the use of the battery monitoring service has been completed, to reduce the overhead.
Note: After your app calls the voltmx.os.unregisterBatteryService API, the callback function registered by the voltmx.os.registerBatteryService API is no longer invoked.
Syntax
Input Parameters
None
Example
Return Values
None
Platform Availability
- iOS
- Android
- Windows
voltmx.os.unregisterSpeechRecognizer
Deregisters existing (already registered with voltmx.os.registerSpeechRecognizer API) callbacks for speech recognition events.
Syntax
Input Parameters
None.
Example
Return Value
None.
Platform Availability
Available only on Windows.
voltmx.os.userAgent
This API returns a unique identifier of the mobile device that is extracted from the useragent. This unique ID represents the device model and the manufacturer. Volt MX Iris Application Server uses this information to adjust the content to match the screen resolution of the device. For example, the content is adjusted to fit the screen width, height, or memory required etc.
The useragent contains the following information:
- device model
- manufacturer
- OS version
- browser version
- Java capabilities, and so on.
The following are a few sample useragents:
Useragent | Description |
---|---|
Nokia6230i/2.0 (03.25) Profile/MIDP-2.0 Configuration/CLDC-1.1 |
Nokia 6230i model mobile device |
SonyEricssonT610/R501 Profile/MIDP-1.0 Configuration/CLDC-1.0 |
SonyEricsson T610 model mobile device |
Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0) |
Windows Phone mobile device |
OPWV-SDK/62 UP.Browser/6.2.2.1.208 (GUI) MMP/2.0 |
Openwave Mobile Browser 6.2.2 |
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) |
Microsoft Internet Explorer 6 |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 |
Mozilla Firefox 1.0.7 running on Windows 2000 |
Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10 |
iPad |
Device Model. For example, Galaxy Nexus. |
Android and Android Tablet. |
You can use this API in the following scenarios when you need to identify:
- The model of a specific mobile device.
- The mobile devices based on the manufacturer.
- If the device is a web browser, mobile device, micro browser, or a computer.
Syntax
voltmx.os.userAgent()
Input Parameters
None
Example
In the following example, the uid returned by the voltmx.os.userAgent is displayed in the alert.
Return Values
Device ID [String]
Any of the available Device ID is returned in the order Device Model, OS Version, Browser Version, Java Capabilities, and Manufacturer.
Note:
- For Android and Android Tablet, device model is returned as an user agent.
- For iOS Devices, user agent is returned as a string.
Platform Availability
Available on all platforms.