Most mobile apps assume the network is there. Field apps cannot. An engineer on a 100MW solar site or an operator in a steel shed needs to record progress, attendance and issues for hours without signal, and trust that nothing is lost when connectivity returns.
Offline-first is not a feature you add later. It is an architecture decision that shapes the data model, the API and the user interface.
The local database is the source of truth on the device
Every read and write goes to a local database (we use WatermelonDB or SQLite). The app never waits for the network to show data or accept input. Synchronisation is a background concern.
Design the sync protocol before the screens
A sync protocol defines what changed, in which order and how conflicts resolve. We use change tracking with per-record versions and a pull/push cycle: pull server changes since the last sync, push local changes, resolve conflicts by rule.
- Last-writer-wins for simple fields such as notes
- Server-wins for financial or statutory fields
- Merge rules for counters and checklists
- Explicit user review for genuine conflicts on critical records
Make identity and ordering safe
Records created offline need globally unique IDs generated on the device, and operations need timestamps that survive clock drift. We generate UUIDs on the client and let the server assign authoritative sequence numbers on arrival.
Attachments and photos
Photos are evidence on site. We compress on device, queue uploads separately from data sync and show upload state in the UI so engineers know what is pending. Data syncs first; media follows.
Battery, storage and old phones
Field devices are often mid-range Android phones with little free storage. We cap local data by age, batch GPS reads, and test on the slowest device the client owns. An app that drains the battery by noon is an app that gets uninstalled.
Show the state of sync honestly
Users trust an app that tells them the truth: how many records are pending, when the last sync happened and whether anything failed. Hiding sync state is the fastest way to lose confidence in the data.