The VMXFoundry.OfflineObjects.startSync API performs sync on all the object services published in the Volt MX Foundry application.
Note:
If sync is performed in an upload cache enabled scenario, cached requests that are timed out in the previous upload session are uploaded before the latest changes.
The client does not handle partial records and expects the server to send the entire record. Full record with all the columns are expected in both upload and download responses. If the backend does not return the full record, use post processor to copy the missing columns from the request as demonstrated here.
removeAfterUpload flag is only applicable for uploadOnly sync type.
removeAfterUpload flag has no effect if it is set to downloadOnly or fullSync types.
removeAfterUpload flag doesn’t clear entire local DB. It deletes the record that are only successfully uploaded during uploadOnly syncType.
Client can do downloadOnly sync to get local deleted records back to local DB.
removeAfterUpload flag is applicable for all three-level sync (app level, obj svc, and obj).
Volt MX Iris (JavaScript)
Note:
Supported for Windows from V8 SP4 Fix Pack 6 onwards.
Supported for Mobile Web and Desktop Web channels from V8 SP4 Fix Pack 12 onwards.
The user can provide options to customize sync behavior. For example, syncMode and objectServicesOptions. For information on supported options, refer to Sync Options.
Yes
successCallback
Function
The function is invoked on successful sync with response as an argument. Based on the supplied sync options, the response object includes sync status code, sync stats and so on.
Yes
failureCallback
Function
The function is invoked on an error with the cause of failure as an argument upon sync failure.
Yes
progressCallback
Function
The function is invoked on different sync phases along with specific data such as the number of downloaded records and so on. Note: This parameter is only supported for Android, iOS, and Windows channels.
No
Sync Options
Option
Type
Description
Required
syncMode
String
Option to perform object services sync in sequence or parallel. The values could be { "parallel", "sequential" } Note: Default sync mode is parallel, if not provided in options.
No
objectServicesOptions
JSON
The user can provide options to customize sync behavior. For example, Filters, downloadBatchSize and so on. For more details, refer Sync Options for supported options and Offline Objects Getting Started guide.
No
removeAfterUpload
Array (list of objects)
removeAfterUpload flag removes the entries from local DB once upload is successful to backend DB. This flag is passed as option parameter to startSync function as part of sync options.
No
Success Callback Response
Success Object Keys
Type
Description
successResponse
JSON
It contains object service name as keys and object service sync success response as values.
Failure Callback Error
Failure Object Keys
Type
Description
successResponse
JSON
It contains object service name as keys and object service sync success response as values.
failureResponse
JSON
It contains object service name as keys and object service sync failure response as values.
var appLevelOptions = {
"syncType": "uploadOnly"
};
var syncOptions = {};
syncOptions.objectServicesOptions = {
"<ObjSvc>": appLevelOptions,
};
syncOptions.removeAfterUpload = [<list of objects>];
syncOptions.isUploadCacheEnabled=true;
voltmx.sdk.OfflineObjects.startSync(syncOptions, onSuccess, onFailure, onProgress);
function onSuccess(response)
{ //Handle sync success response. }
function onFailure(error)
{ //Handle sync failure response. }
function onProgress(object)
{ //Handle sync progress response. }
Android (Java)
Signature
void <OfflineObjects>.startSync(final HashMap<String, Object\> options, final VMXCallback syncCallback, final VMXProgressCallback voltmxSyncProgressCallback)
Parameters
Parameter
Type
Description
Required
options
HashMap<String, Object>
The user can provide options to customize sync behavior. For example, syncMode and objectServicesOptions. For supported options, refer Sync Options.
Yes
syncCallback
VMXCallback
The application implements onSuccess and onFailure methods of VMXCallback interface.
Yes
voltmxSyncProgressCallback
VMXProgressCallback
Application implements onProgress method of VMXProgressCallback interface if progress callback is supplied.
Yes
Sync Options
Option
Type
Description
Required
syncMode
String
Option to perform object services sync in sequence or parallel. The values could be { "parallel", "sequential" } Note: Default sync mode is parallel, if not provided in options.
No
objectServicesOptions
HashMap<String, Object>
The user can provide options to customize sync behavior. For example, Filters, downloadBatchSize and so on. For more details, refer Sync Options for supported options and Offline Objects Getting Started guide.
No
Success Callback Response
Success Object Keys
Type
Description
successResponse
HashMap<String, Object>
It contains object service name as keys and object service sync success response as values.
Failure Callback Error
Failure Object Keys
Type
Description
userInfo
HashMap<String, Object>
It contains HashMaps with keys successResponse and failureResponse. successResponse contains HashMap of object service name as keys and object service sync success response as values. failureResponse contains HashMap of object service name as keys and object service sync failure response as values.
The user can provide options to customize sync behavior. For example, syncMode and objectServicesOptions. Refer Sync Options for supported options.
Yes
onSuccess
VMXSuccessCompletionHandler
The function is invoked on successful sync.
Yes
onFailure
VMXFailureCompletionHandler
The function is invoked on sync failure.
Yes
onProgress
VMXProgressCompletionHandler
The function is invoked on sync progress events.
Yes
Sync Options
Option
Type
Description
Required
syncMode
String
Option to perform object services sync in sequence or parallel. The values could be { "parallel", "sequential" } Note: Default sync mode is parallel, if not provided in options.
No
objectServicesOptions
NSDictionary
The user can provide options to customize sync behavior. For example, Filters, downloadBatchSize, and so on. For more details, refer Sync Options for supported options and Offline Objects Getting Started guide.
Yes
Sync Callback Response
Success Object Keys
Type
Description
successResponse
NSDictionary<NSString*, id>*
It contains object service names as keys and object service sync success response as values.
Failure Callback Error
Failure Object Keys
Type
Description
userInfo
NSDictionary <NSString*, id>*
It contains NSDictionaries with keys successResponse and failureResponse keys. successResponse contains NSDictionary of object service name as keys and object service sync success response as values. failureResponse contains NSDictionary of object service name as keys and object service sync failure response as values.