About Sync Statuses
To enable full control over “in-flight” sync operations, Mobile SDK 7.1 adds a new
status that indicates that the operation has been stopped.
Before Mobile SDK 7.1,
each sync operation progressed through a cycle of statuses: new, running, and either failed or done. Mobile SDK 7.1 adds a stopped status to the final step, changing the cycle as follows:
- new
- running
- stopped | failed | done
When key events occur, sync statuses are updated as follows.
| Event | Previous Status | Reported Status |
|---|---|---|
| App creates a sync object | — | new |
| Sync object is submitted for running by a call to a sync down or sync up method, or by a first call to reSync | new | running |
| Sync operation completes successfully | running | done |
| Sync operation fails to complete | running | failed |
| A sync manager stop request is detected | running | stopped |
| Sync manager restarts with the restartStoppedSyncs parameter set to true | stopped | running |
| reSync is called | stopped/failed/done | running |
Getting Sync Objects by Status
Beginning with Mobile SDK 7.1, sync manager objects support a getSyncsWithStatus
method that returns all sync state objects whose status matches a given value. You can use this
method, for example, to iterate through all stopped syncs and restart them manually.
iOS
- Swift
-
1open class func getSyncsWithStatus(_ store: SmartStore, 2 status: SyncStatus) -> [SyncState] - Objective-C
-
1+ (NSArray<SFSyncState>) getSyncsWithStatus:(SFSmartStore*)store 2 status:(SFSyncStateStatus)status;
Android
(Java)
1public static List<SyncState> getSyncsWithStatus(SmartStore store, Status status)