About Sync Task Errors

In Mobile SDK 7.1 and later, sync task methods return error information consistently across platforms.

Sync tasks—sync down, sync up, resync, and clean resync ghosts—can fail for the following reasons:

  • Invalid ID or name
  • The requested sync operation is already running
  • Sync manager is stopped or stopping
  • On iOS:

    • Swift methods throw a SyncState object.
    • Objective-C methods include an NSError** parameter. Earlier versions of these methods are deprecated.
  • On Android, these methods throw MobileSyncException.

New and Updated Sync and Resync Methods in Mobile SDK 7.1 

New iOS Methods 

Objective-C

The following methods now support and NSError parameter.

1- (nullable SFSyncState*)
2    syncDownWithTarget:(SFSyncDownTarget*)target
3               options:(SFSyncOptions*)options
4              soupName:(NSString*)soupName
5              syncName:(*nullable* NSString*)syncName
6           updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock
7                 error:(NSError**)error
8;
9- (*nullable* SFSyncState*)
10    syncUpWithTarget:(SFSyncUpTarget*)target
11             options:(SFSyncOptions*)options
12            soupName:(NSString*)soupName
13            syncName:(*nullable* NSString*)syncName
14         updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock
15               error:(NSError**)error;
16
17- (*nullable* SFSyncState*)
18         reSync:(NSNumber*)syncId
19    updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock
20          error:(NSError**) error;
21
22- (*nullable* SFSyncState*)
23    reSyncByName:(NSString*)syncName
24     updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock
25           error:(NSError**)error NS_SWIFT_NAME(reSync(named:onUpdate:));

Updated iOS Methods 

Swift

The following methods now throw a SyncState object.

1open func syncDown(target: SyncDownTarget,
2                  options: SyncOptions,
3                 soupName: String,
4                 syncName: String?,
5     onUpdate updateBlock: @escaping SyncUpdateBlock) throws -> SyncState
6
7open func syncUp(target: SyncUpTarget,
8                options: SyncOptions,
9               soupName: String,
10               syncName: String?,
11   onUpdate updateBlock: @escaping SyncUpdateBlock) throws -> SyncState
12
13open func reSync(id syncId: NSNumber,
14      onUpdate updateBlock: @escaping SyncUpdateBlock) throws -> SyncState
15
16open func reSync(
17          named syncName: String,
18    onUpdate updateBlock: @escaping SyncUpdateBlock) throws -> SyncState

Deprecated iOS Methods in Mobile SDK 7.1 

Objective-C

Existing sync methods that do not support an NSError output parameter are slated for removal in a future major release.

1- (nullable SFSyncState*)
2    syncDownWithTarget:(SFSyncDownTarget*)target
3               options:(SFSyncOptions*)options
4              soupName:(NSString*)soupName
5              syncName:(*nullable* NSString*)syncName
6           updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock;
7
8- (nullable SFSyncState*)
9    syncUpWithTarget:(SFSyncUpTarget*)target
10             options:(SFSyncOptions*)options
11            soupName:(NSString*)soupName
12            syncName:(*nullable* NSString*)syncName
13         updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock;
14
15- (nullable SFSyncState*)
16         reSync:(NSNumber*)syncId
17    updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock;
18
19- (nullable SFSyncState*)
20    reSyncByName:(NSString*)syncName
21     updateBlock:(SFSyncSyncManagerUpdateBlock)updateBlock;

See Also 

For changes to cleanResyncGhosts methods, see Handling “Ghost” Records After Sync Down Operations.

We've Moved

Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.