Skip to content

Application Level APIs

The application level API facilitates in set up and initialize the Offline Objects client-side environment, drop or reset the client state (database).

VMXFoundry.OfflineObjects.setup

Offline Objects setup function initializes the creation of device database and sync environment. Once the setup is successful, the database structure is created on the device. The device database does not have any data. Every app launch must call setup before using any other offline objects API, subsequent VMXFoundry.OfflineObjects.setup call initializes the sync environment.

Syntax

VMXFoundry.OfflineObjects.setup(options, successCallback, failureCallback)

Input Parameters

ParameterTypeDescriptionRequired
optionsJSONDevice database encryption passphrase and so on.Yes
successCallbackFunctionThe function is invoked on successful setup.Yes
failureCallbackFunctionThe function is invoked on error in setup with the cause of failure as an argument.Yes

Example

function successCallback(){
    voltmx.print("Application setup successful");
}
function failureCallback(error){
    voltmx.print("Application setup failed with error:" + error.code);
}
//Encrypt the device database using a passphrase
var options = {"deviceDbEncryptionKey" : "myencryptionpa$$phrase1"};
VMXFoundry.OfflineObjects.setup(options, successCallback, failureCallback);

VMXFoundry.OfflineObjects.drop

The function deletes the database schema along with all its data. Success or failure is reported through callbacks provided to the drop API.

Syntax

VMXFoundry.OfflineObjects.drop(options, successCallback, failureCallback)

Input Parameters

ParameterTypeDescriptionRequired
optionsJSONDrop options such as device database encryption passphrase and so on.Yes
successCallbackFunctionThe function is invoked when drop operation is successful.Yes
failureCallbackFunctionThe function is invoked on error while dropping with the cause of failure as an argument.Yes
Option Type Description Required
deviceDBEncryptionKey String Encryption passphrase must be a string of six characters long. No

Example

function successCallback(){
  voltmx.print("Application drop successful");
}
function failureCallback(error){
  voltmx.print("Application drop failed with error:" + error.code);
}
//Encrypt the device database using a passphrase
var options = {"deviceDbEncryptionKey" : "myencryptionpa$$phrase1"};
VMXFoundry.OfflineObjects.drop(options, successCallback, failureCallback);

VMXFoundry.OfflineObjects.reset

Offline objects reset function resets the device database to the initial stage of the sync environment. Once the reset is successful, all the data is removed from the database but the database table structure is preserved.

Syntax

VMXFoundry.OfflineObjects.reset(options, successCallback, failureCallback)

Input Parameters

ParameterTypeDescriptionRequired
optionsJSONReset options such as device database encryption passphrase and so on.Yes
successCallbackFunctionThe function is invoked on successful reset.Yes
failureCallbackFunctionThe function is invoked on an error in reset with the cause of failure as an argument.Yes
Option Type Description Required
deviceDBEncryptionKey String Encryption passphrase must be a string of six characters long. No

Example

function successCallback(){
  voltmx.print("Application reset successful");
} 
function failureCallback(error){
   voltmx.print("Application reset failed with error:"+ error.code);
} 
//Decrypt and re encrypt the device database
var options={"deviceDBEncryptionKey":"myencryptionpa$$phrase1"};
VMXFoundry.OfflineObjects.reset(options,successCallback, failureCallback);

VMXFoundry.OfflineObjects.rollback

Offline objects rollback function rolls back all the changes of the application in the device local database to its previous sync state.

Syntax

VMXFoundry.OfflineObjects.rollback(successCallback, failureCallback)

Input Parameters

ParameterTypeDescriptionRequired
successCallbackFunctionThe function is invoked on a successful rollback.Yes
failureCallbackFunctionThe function is invoked on rollback failure with the cause of failure as an argument.Yes

Example

function successCallback(){ 
    voltmx.print("Application rollback successful");
} 
function failureCallback(error){
    voltmx.print("Application rollback failed with error:" + error.code);
}
VMXFoundry.OfflineObjects.rollback(successCallback, failureCallback);