Offline data is a critical feature typically requested by customers. Salesforce Mobile SDK provides useful features for SmartStore to provide data to mobile users offline.
All data requests in SmartSync apps are asynchronous. “Asynchronous” means that the sync method you call returns the server’s response in a callback method or update block that you define. Each sync-down or sync-up method call returns a sync state object that contains the following information:
- Sync operation ID. You can check the progress of the operation at any time by passing this ID to the sync manager’s getSyncStatus method.
- Your sync parameters (soup name, target for sync down operations, options for sync up operations).
- Type of operation (up or down).
- Progress percentage (integer, 0–100).
What if the user needs to be able to create, update or delete data?
- Any time a record is upserted or deleted in the app, the local copy of that record is upserted or deleted and a queue record is created too.
- If the app is online, the record can be upserted or deleted in Salesforce.com immediately and the queue record can be deleted.
- Since the queue record isn’t deleted until a successful response is received from the Salesforce API, this ensures that no data will be lost regardless of whether the device is online, offline, or has a bad connection and a synchronization error occurred during data transfer.