Browse Mobile App Development Section 7: Native Platform Features

Run Background Work

2 fill-in slots · from The AI Prompt Handbook for Mobile App Development

Your details

0/2 filled

Run Background Work

Background: Native [platform] app, [SwiftUI+Combine / Compose]. I need to
do work when the app isn't foregrounded: [sync data / refresh content /
upload queued items / process downloads]. Timing need: [periodic /
opportunistic / triggered by event].

Use case: Schedule background work that survives OS restrictions and
doesn't get the app throttled or killed.

Implementation details:
- iOS: BGAppRefreshTask vs BGProcessingTask, registration and scheduling,
  the short execution windows, and why background time is never
  guaranteed. Background URLSession for transfers.
- Android: WorkManager for deferrable/guaranteed work, constraints
  (network/charging), and Doze/App Standby effects; foreground service
  only when user-visible work demands it.
- Idempotent, resumable work that tolerates being interrupted
- Respecting battery and the OS's right to defer or skip the task
- Testing background execution (it won't behave like the foreground)

Layer & dependencies: Background tasks call into the same data-layer sync
logic the foreground uses—no duplicated logic.

Deliverable: The background-work design for my need, the scheduling/
constraints setup per platform, the idempotency/resumability approach,
the OS-limitation caveats, and how to test it.

Highlighted [slots] are still empty. Downloads are plain .txt — paste into any AI assistant.