Skip to main content

Offline usage (mobile)

LifeWell's mobile apps are offline-first. Every log you create — water entry, medication dose, mood, memory, note — writes to local storage first and reaches Firestore when network connectivity is available. The pattern works on the web app too, but on mobile (especially Android with consistent local storage), the offline guarantees are stronger.

This page covers what works offline, what doesn't, how sync resumes, and the architecture.

What works offline

FeatureOffline-capableNotes
Log waterYesPersists locally, syncs on reconnect
Log vitalsYesSame pattern
Log medicationsYesSame pattern
Log sleep / mood / nutritionYesSame pattern
Log baby eventsYesFeeding, diapers, sleep, milestones
View past entriesYesCached locally for offline reading
Create memory metadataYesMetadata persists; media upload queued
Create note (text / checklist)YesPersists locally
Create note (audio / picture)QueuedMedia uploads when online
Fire local notificationsYesDoesn't need network
Read profile / settingsYesCached
Browse community feedCachedNewest posts need network
Send chat messageQueuedSends on reconnect
Update theme / preferencesYesLocal + syncs
Run calculators / timersYesAll client-side

What does NOT work offline

FeatureWhy not
Initial sign-inOAuth requires network
Cross-device syncSync needs network
Push notifications receivedRequires network for delivery
Photo / video uploadsNeed Google Drive connectivity
Community postingRequires network
Chat receiving (new messages)Requires network
Cloud Functions calls (rare)Requires network
Consultation bookingRequires network

The architecture prioritises personal data entry (the most-used flows) for offline support. Social, cross-device, and media-upload flows degrade gracefully when offline.

The storage stack

LifeWell mobile persistence has three layers:

LayerWhatUse
Capacitor PreferencesKey-value store backed by SharedPreferences (Android) / UserDefaults (iOS)App settings, auth token, UI state
Firestore offline cacheIndexedDB (web) / SQLite (mobile) — Firestore's built-in offline persistenceDocument reads / writes with automatic sync
FileSystem / IndexedDBCapacitor filesystem + browser IndexedDBLarger blobs (cached images, attached files)

The split is intentional: small settings via Preferences (fast, key-value), structured data via Firestore (queryable, syncable), large blobs via filesystem (size-efficient).

Write flow when offline

  1. You tap "Log 250 ml water" on a flight (offline).
  2. The Zustand water store adds the entry, persisted to Capacitor Preferences.
  3. The Firestore SDK queues the write to its offline cache.
  4. The UI updates immediately — today's count goes up by 250 ml.
  5. The page shows a tiny "offline" indicator if connectivity is lost.

Sync flow when network returns

  1. Device detects connectivity (via Capacitor @capacitor/network + the Firestore SDK's own connection monitoring).
  2. Firestore SDK drains its offline-write queue.
  3. Each queued write replays to Firestore.
  4. Server-side timestamps and IDs reconcile.
  5. The Zustand store updates with reconciled IDs.
  6. Other devices signed into the same account receive the new entries via their Firestore snapshot listeners (typically within seconds of write completion).

The reconciliation is essentially transparent. Most users don't notice anything beyond the offline indicator disappearing.

Conflict resolution

What if you log conflicting data on two devices while both are offline?

Firestore's offline mode handles this via last-write-wins at the document level — the most recent write timestamp prevails. For LifeWell:

  • Adding new records (a new water log, a new memory): both records survive — they have different IDs, so no conflict.
  • Editing an existing record (changing the amount of an existing water log): the most recent edit wins. The earlier device's edit is lost.
  • Deleting a record: deletions propagate; if Device A deletes while Device B edits, the deletion wins (the record is gone everywhere).

For the LifeWell use case (personal-data tracking, not collaborative editing), last-write-wins is correct. No CRDTs or complex merge logic needed.

Offline cache size

The Firestore offline cache and Capacitor Preferences combined typically use:

  • 10–50 MB for a typical user with 6–12 months of activity.
  • 100+ MB for heavy users with many memories or long-term tracking.
  • 500 MB+ uncommon — usually photo-cache rather than data.

Mobile app sizes (including cache) typically stay under 200 MB total. Users can clear cache via OS Settings → LifeWell → Storage.

Photo and media offline

For memory media (photos, videos, audio):

  • Capture the media — saved to device cache immediately.
  • Memory metadata writes to Firestore offline queue.
  • Media upload to Google Drive queues until online.
  • When online, the upload runs and the memory's media[] array gets the Drive file IDs.

So you can create a memory with photos while offline. The memory is visible; the photos show "uploading" placeholders until the actual upload completes.

Local notifications work offline

A key reliability benefit:

  • Local notifications (water reminders, medication doses, sleep reminders) are scheduled on the device via AlarmManager (Android) / UNUserNotificationCenter (iOS).
  • They fire even when the device has no network.
  • Push notifications (from servers) need network — they don't deliver if offline.

So your daily reminders work on a flight, a remote camping trip, anywhere offline.

Browser offline (web app)

The web app uses Firestore's offline persistence too — same write-locally, sync-on-reconnect pattern. The differences from mobile:

  • No local notifications — web reminders only fire when the tab is open.
  • IndexedDB has stricter quotas (a few hundred MB typically; browser-dependent).
  • Service workers can persist some state but PWA installation is required for full offline.

For heavy offline use (international travel, remote work), the mobile app is more reliable than the web app on mobile browsers.

Diagnosing offline issues

IssueCauseFix
Entry I logged offline isn't on my other deviceSync hasn't run since device came onlineOpen the offline device — sync fires within seconds
App shows "offline" but I have wifiCaptive portal blocking outbound trafficTry mobile data or different wifi
Photos stuck at "uploading"Google Drive token expiredRe-sign-in to Drive in Settings
Old entries missingCache evicted (rare; happens on low-storage devices)Pull-to-refresh — re-fetches from Firestore

What offline mode is not

  • Not a replacement for online sync — your data needs to reach Firestore eventually to back up and cross-sync.
  • Not unlimited — local storage has device limits.
  • Not encrypted client-side — Firestore offline cache uses OS-level encryption (e.g. Android keystore for cache key) but isn't end-to-end encrypted across the network on sync.
  • Not collaborative offline — multi-user concurrent offline edits don't merge; last-write wins.

Frequently asked

How long can I stay offline? Indefinitely for entry tracking — until you fill the device's storage or the Firestore offline cache hits its limit. New entries keep queueing. Once online, sync drains the queue (which may take a minute for a large backlog).

What happens if the app is uninstalled before I went online to sync? The unsynced data is gone with the install. Capacitor Preferences and Firestore cache live in the app's sandbox; uninstalling the app removes them. If sync matters, get online before uninstalling.

Can I force a sync? Pull-to-refresh on most lists triggers a sync. Or background-fetch picks it up within ~30 min idle.

Why does Firestore say "cache offline" when I'm online? First read after launch goes from cache; the snapshot listener attaches in the background and updates if anything's new. This is by design — instant display from cache while network catches up.

Does the offline cache contain my media? Thumbnails yes; full-resolution media stays in Google Drive (not cached locally beyond display). Audio files cache locally for offline playback.


Last updated: 2026-05-11 Author: Ahsan Mahmood