# Auto Sync

Saral App is used in the field to collect data, but the challenge is in few remote places there is no internet connectivity all the time. So once useres login to Saral App, scanned data is initially stored in mobile local storage. Users can manually sync data to Saral backend by clicking on the `Save All Scans` button. `Auto Sync` feature polls data in local storage at a frequency and pushes it to the backend.&#x20;

This feature is available from `v1.0.0-beta.5` release and above.

![](https://811030052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLe89Gzl6JNQ9inpB8sRg%2Fuploads%2FrVYTOzC3ikHWgiHJyR8o%2Fsync-1.jpeg?alt=media\&token=56c2ead1-5bbf-4fa4-a920-be0c46b96929)![](https://811030052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLe89Gzl6JNQ9inpB8sRg%2Fuploads%2F3cAycVcIMYI2bxO68fJN%2Fsync-2.jpeg?alt=media\&token=1cba5366-7f28-490a-b494-e56f9ea69462)

&#x20; ![](https://811030052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLe89Gzl6JNQ9inpB8sRg%2Fuploads%2Fyb6gle3fDVtIibaWbemT%2Fsync-7.jpeg?alt=media\&token=ab8683f9-6373-428f-a90f-ea193d1970bc)![](https://811030052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLe89Gzl6JNQ9inpB8sRg%2Fuploads%2FG48Hw0k9oo2NpQGvMwch%2Fsync-3.jpeg?alt=media\&token=1b48f6fc-a714-467a-a2b5-27df6c99c6f5)

Auto Sync can be controlled by following configuration:

```
autoSynch - boolean
autoSynchFrequency - integer
autoSyncBatchSize - integer
```

`autoSynch` is a boolean property in `/schools/login` API response. if it's set to true then Auto Sync process will be enabled.

`autoSynchFrequency` is frequency at which auto-synch to be executed.&#x20;

`autoSyncBatchSize` is batch size for auto-sync functionality. Auto-sync triggers based on number of records available in local storage. if its minimum of `autoSyncBatchSize` and other configuration matches, auto sync to backend will be triggered in mobile app. Default value if not set is 10.

`/schools/login` API response with `autoSynch` and `autoSynchFrequency` configuration reference.

```
{
"school" : {
    "storeTrainingData" : true,
    "name" : "Dummy school 4",
    "schoolId" : "u002",
    "state" : "up",
    "autoSynch" : true,
    "autoSynchFrequency" : 9000,
    "autoSyncBatchSize": 20
}
}
```
