docs/long-term-plans/android-background-sync-improvements.md
Status: Planned
Owner / tracking: Unassigned; create an issue before implementation.
Last verified: 2026-07-29
Android WorkManager polls the SuperSync server approximately every 15 minutes. When it detects that a task was completed, deleted, rescheduled, or had its reminder cleared on another device, it updates or cancels the stale Android notification. This works but leaves a delay before native reminders reflect a remote change.
This document records:
The background worker's lastServerSeq is not proof that operations were
stored in the operation log or applied to Angular state. It only records how far
the native reminder worker has scanned while updating notifications.
Therefore:
getLastSyncSeq() or seed the foreground
provider's sinceSeq from it.Violating this boundary can permanently omit remote task changes from the app. Any future shared background-sync cache would need to store the actual operations and transfer them through the same durable apply/checkpoint path as a normal foreground download. That is a separate sync design, not a reminder optimization.
WorkManager's minimum periodic interval is 15 minutes. A user could complete a task on their desktop and still receive the reminder on their phone if it fires within that window.
Use Firebase Cloud Messaging (FCM) to push a lightweight signal from the SuperSync server when reminder-relevant operations occur. The Android app receives the push and immediately cancels the stale notification.
This is not approved implementation work. It requires a tracked privacy, operations, and product decision because it adds Google infrastructure, device registration, server state, and a new delivery path.
{ "type": "reminder_change", "seq": 12345 }FirebaseMessagingService receives the data messagelastServerSeq from SharedPreferenceslastServerSeq to the new seq using the existing SuperSyncBackgroundProviderSyncReminderWorkerlastServerSeqKeep the 15-minute WorkManager poll as a fallback. FCM delivery is best-effort — messages can be delayed or dropped by the OS (Doze mode, battery optimization). The worker ensures eventual consistency even if FCM fails.
FCM push (immediate, best-effort)
↓
Cancel notification
↓
WorkManager poll (15-min, guaranteed)
↓
Cancel any remaining stale notifications
SyncFirebaseMessagingService extending FirebaseMessagingServiceThe BackgroundSyncProvider interface already supports this. A Dropbox implementation would:
sync-data.json (~100KB+) via the Dropbox APIThis is heavier than SuperSync's operation-based API but workable for the ~15-minute poll interval. WebDAV would be similar.
Key difference: Dropbox/WebDAV providers would need to cache the previous state locally to compute diffs, adding storage overhead. SuperSync's seq-based pagination avoids this entirely.
DropboxBackgroundProvider implementing BackgroundSyncProviderWebDavBackgroundProvider implementing BackgroundSyncProviderSyncReminderWorker based on stored provider ID| Candidate | Effort | Impact | Recommendation |
|---|---|---|---|
| FCM push | Large (~1 week, needs server changes) | High — faster cancellation | Only after privacy/product/operations approval |
| Other sync providers | Medium per provider | Medium — broader coverage | Only in response to demonstrated provider demand |
| Reminder cursor as a hint | Small | Unsafe — can skip user data | Rejected; preserve the safety fence above |