<objectService>.cancelSync
The <objectService>.cancelSync function cancels an in progress object service sync operation. The operation fails if the task syncing is already finished, throws an error, or does not support the Cancel operation.
Quantum Visualizer (JavaScript)
NOTE:
- Not supported for Mobile Web and Desktop Web channels.
- Supported for Windows from V8 SP4 Fix Pack 12 onwards.
Signature
KNYObjSvc.cancelSync(Options, onSuccess, onFailure)
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
Options | JSON | Reserved for future use, so the parameter is insignificant. But, the developer must pass some value such as null or { }. | Yes |
onSuccess | Function | The JavaScript function to be executed when cancellation is successful. | Yes |
onFailure | Function | The JavaScript function to be executed when cancellation fails. | Yes |
Return Type
void
Example
var syncObjectSvc = new kony.sdk.KNYObjSvc("Organization"); // define Sync options var syncOptions = {}; syncOptions.downloadBatchSize = 100; syncOptions.uploadBatchSize = 200; syncOptions.getSyncStats = true; // Start Sync asynchronously syncObjectSvc.startSync(syncOptions, function(res) { alert("ObjectService sync successful"); }, function(err) { alert("ObjectService sync failed with error: " + JSON.stringify(err)); }, function(progressCallback) { alert("ObjectService sync progress event received"); }); // Now attempt to Cancel Sync// passing an empty map for options parameter syncObjectSvc.cancelSync({}, function(res) { alert("ObjectService sync cancellation successful"); }, function(err) { alert("ObjectService sync failed with error : " + JSON.stringify(err)); });
Android (Java)
Signature
public void cancelSync(HashMap<String, Object> options, final KNYCallback syncCancellationCallback)
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
options | HashMap<String, Object> | Reserved for future use, so the parameter is insignificant. But, the developer must pass some value such as null or new HashMap<String, Object>(). | Yes |
syncCancellationCallback | KNYCallback | Application implements onSuccess and onFailure methods of KNYCallback interface. |
Yes |
Return Type
void
Example
KNYObjSvc syncObjectSvc = new KNYObjSvc("Organization"); // Define Sync options HashMap < String, Object > syncOptions = new HashMap < String, Object > (); syncOptions.put("downloadBatchSize", "100"); syncOptions.put("uploadBatchSize", "200"); syncOptions.put("getSyncStats" "true"); // Start Sync asynchronously syncObjectSvc.startSync(syncOptions, new KNYCallback() { @Override public void onSuccess(Object object) { Log.d("ObjectServiceSync", "ObjectService sync successful"); } @Override public void onFailure(Object error) { Log.e("ObjectServiceSync", "ObjectService sync failed with error: " + error); } }, new KNYProgressCallback() { @Override public void onProgress(Object object) { Log.d("ObjectServiceSync", "ObjectService sync progress event received"); } }); // Now attempt to Cancel Sync // passing an empty HashMap for options parameter syncObjectSvc.cancelSync(new HashMap < String, Object > (), new KNYCallback() { @Override public void onSuccess(Object object) { Log.d("ObjectServiceSync Cancellation", "ObjectService sync cancellation successful"); } @Override public void onFailure(Object error) { Log.e("ObjectServiceSync Cancellation", "ObjectService sync cancellation failed with error: " + error); } });
iOS (Objective C)
Signature
(void)cancelSync:(NSDictionary *)options onSuccess:(KNYSuccessCompletionHandler)onSuccess onFailure:(KNYFailureCompletionHandler)onFailure
Parameters
Parameter | Type | Description | Required |
onSuccess | KNYSuccessCompletionHandler | The method called after a successful cancellation. | Yes |
onFailure | KNYFailureCompletionHandler | The method called after the cancellation fails. | Yes |
Return Type
void
Example
NSError * error; KNYObjSvc * syncObjectSvc = [ [KNYObjSvc alloc] initWithName: @"Organization" error: & error ]; // Define Sync options NSMutableDictionary * syncOptions = [NSMutableDictionary new]; [syncOptions setObject: @"100" forKey: @"downloadBatchSize" ]; [syncOptions setObject: @"200" forKey: @"uploadBatchSize" ]; [syncOptions setObject: @"true" forKey: @"getSyncStats" ]; // Start Sync asynchronously [syncObjectSvc startSync: syncOptions onSuccess: ^ (id object) { NSLog(@"ObjectService sync successful"); } onFailure: ^ (NSError * error) { NSLog(@"ObjectService sync failed with error :%@", [error description]); } onProgress: ^ (id object) { NSLog(@"ObjectService sync progress event received"); } ]; // Now attempt to Cancel Sync// passing an empty dictionary for options parameter NSMutableDictionary * cancelSyncOptions = [NSMutableDictionary new]; syncObjectSvc cancelSync: cancelSyncOptions onSuccess: ^ (id object) { NSLog(@"ObjectService sync cancellation successful"); } onFailure: ^ (NSError * error) { NSLog(@"ObjectService sync cancellation failed with error: %@", [error description]); }];