voltmx.application.settings Namespace
The voltmx.application.settings Namespace provides the following API elements.
Functions
voltmx.application.settings.read
This function enables your app to read the configuration values associated with specified keys.
Syntax
Input Parameters
Parameters | Description |
---|---|
key | A string that specifies the keys for the settings to read. |
onsuccesscallback | A function that is executed when the key-value pair specified in the key parameter is read successfully. For details, see the Remarks section below. |
onfailurecallback | A callback function is executed when there is an error in fetching the app’s settings. This callback function receives the error code and the error message. For details, see the Remarks section below. |
Example
Return Values
None.
Remarks
This function reads an app’s settings from the settings file that is bundled with the application’s binary. Your app can use this function to read, among other things, the user-defined values such as the preferred locations.
This is an asynchronous call so it returns immediately. Upon successfully reading the app’s settings, the Volt MX Iris API framework automatically invokes the callback your app passes in the onsuccesscallback parameter. The callback function has the following signature.
onsuccess(key, value);
When this callback function is invoked, the key parameter contains a string that specifies the name of the key whose value is being retrieved.
The value parameter contains the settings that were read. It can be Boolean
, string
, double
, or an object. It contains an object when Display option is set to multiselect.
If the Volt MX Iris API framework cannot read the settings associated with the key parameter to the voltmx.application.settings.read
function, then the framework automatically invokes the function in the onfailurecallback parameter. The callback function has the following signature.
onfailure(errorcode,errormessage);
When the framework calls the onfailure
callback function errorcode parameter of contains a numeric error code and the errormessage parameter contains the corresponding error message as a string
.
Platform Availability
Available only on iPhone
voltmx.application.settings.write
This function enables your app to write values associated with specified keys.
Syntax
Input Parameters
Parameter | Description |
---|---|
key | A string that specifies the unique key. The key that you specify must exist. You cannot introduce a new key. |
value | A string that holds the value to be set for a key. If this function is called multiple times using the same key, existing value for the key is replaced with the new value. A key’s value can be Boolean, string, double, or an object. It can contain an object only when Display option is set to multiselect. |
onsuccesscallback | The callback function that is executed when the new value is successfully assigned to the specified key. For details, see the Remarks section below. |
onfailurecallback | The callback function that is executed when there is an error in updating the configuration. This callback function receives an error code and an error message. For details, see the Remarks section below. |
Example
Return Values
None.
Remarks
This function sets the value of configuration options in the configuration file that is associated with the app. New keys cannot be introduced with this function. Your app can only write to existing keys. This is an asynchronous call, so it returns immediately and does not wait for the underlying hardware to write the value to the specified key. It uses callback functions to communicate success or failure. The callback functions for success and failure are set using this function’s onsuccesscallback and onfailurecallback, respectively.
The callback function for the onsuccesscallback parameter of the voltmx.application.settings.write
function has the following
syntax.
where the key
parameter to this callback is a string containing the name of the key that was set, and the callback function’s value
parameter contains the value that the key was set to. The callback function’s value
parameter can be boolean
, string
, double
, or an object. An object is only passed in through the value parameter when “Display option” is multiselect.
If the voltmx.application.settings.write
function cannot set the value of the specified key, in invokes another callback function. The callback function for the voltmx.application.settings.write
function’s onfailurecallback parameter has the following syntax.
where the errorcode
parameter contains a numeric error code and the errormessage
parameter holds a string that specifies the error message.
Platform Availability
Available only on iPhone