Auto Sync Frequency in CommCare

commcare

Wondering how the auto sync frequency setting in CommCare works in a bit more detail.

For example:

  • Does daily mean once every 24 hours, or 24 hours after the list full sync?
  • Will CommCare trigger a sync only after a login, or after the app being opened after some period of inactivity even if the user is still logged in, or if the user is in the app but only on the start screen, or no matter where the user is in the app, etc.?
  • Any reason why having a higher frequency would be entirely out of the question (ex: every 6 hours or some such)?

Best Answer

When configured for a daily auto-sync, CommCare will attempt to run a sync after the user logs in under any of the following conditions:

  1. It has been more than 24 hours since the previous successful sync
  2. It is a new calendar day since the previous successful sync (IE: If last sync was Tuesday at 9pm, a login on Wednesday at 10am will trigger an autosync)
  3. The "previous" sync time is more than a day in the future, implying that the clock has been significantly manipulated and we need to gain a new ground truth.

Generally the app will never force an autosync after the user has successfully logged in and begun usage, to prevent taking control away from the user for a long, blocking process.

One edge case of this is if a user was in the middle of a form when they were logged out, upon logging back in they should be directed back to that form, and if an autosync is necessary it will trigger after the form is completed. This ensures that the phone's DB state hasn't changed in between starting and completing the form.