Using the Batch Sync Up Target

To enhance performance in large sync up operations, Mobile SDK 7.1 introduces a batch sync up target.
iOS Native Android Native
Swift
BatchSyncUpTarget
Objective-C
SFBatchSyncUpTarget
BatchSyncUpTarget

This target enhances the standard sync up target behavior by calling the Salesforce composite API. The composite API sends local records to the server in batches of up to 25 records.

iOS Native

Swift

1var target = BatchSyncUpTarget.init(createFieldList, updateFieldList)
2let syncMgr = SyncManager.sharedInstance(store: self.store!)
3syncMgr!.syncUp(target: target, options: options, soupName: soupName) {...}

Objective-C

1SFBatchSyncUpTarget* target = [[SFBatchSyncUpTarget alloc] init];
2// or
3SFBatchSyncUpTarget* target = 
4    [[SFBatchSyncUpTarget alloc] initWithCreateFieldlist:createList 
5                                            updateFieldlist:updateList];
6[syncManager syncUpWithTarget:target 
7                      options:options 
8                     soupName:soupName 
9                  updateBlock:updateBlock];

Android Native

1BatchSyncUpTarget target = new BatchSyncUpTarget();
2// or
3BatchSyncUpTarget target = new BatchSyncUpTarget(createFieldlist, updateFieldlist);
4syncManager.syncUp(target, options, soupName, callback);

Hybrid and React Native

Existing sync up targets in hybrid and React Native apps automatically use the batch sync up target. To use a different sync up target implementation such as the legacy SyncUpTarget class, specify “androidImpl” or “iOSImpl”.

Usage in Sync Config Files

By default, sync up targets defined in sync config files use batch APIs. For example, the following sync configuration creates a batch sync up target.

1{ "syncs": [ 
2    { 
3        "syncName": "syncUpContacts", 
4        "syncType": "syncUp", 
5        "soupName": "contacts", 
6        "target": 
7             {"createFieldlist":
8                 ["FirstName", 
9                  "LastName", 
10                  "Title", 
11                  "MobilePhone", 
12                  "Email", 
13                  "Department", 
14                  "HomePhone"]
15             }, 
16        "options": 
17             {"fieldlist":
18                 ["Id", 
19                  "FirstName", 
20                  "LastName", 
21                  "Title", 
22                  "MobilePhone", 
23                  "Email", 
24                  "Department", 
25                  "HomePhone"], 
26        "mergeMode":"LEAVE_IF_CHANGED"} 
27    } 
28]}