Background sync without draining the battery

Platform & distribution Senior Swift 5.0+ iOS 17+ Reviewed By Alok Singh

Pick the fix

Which sync strategy is the most battery-friendly?

Options
Hint 1 of 1

What costs the most energy?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Queue edits locally, batch them, and send in a BGProcessingTask or discretionary background session

Correct. Fewer radio wake-ups at times the system chooses.

Why not the others?
  • B Send every keystroke immediately. Each request wakes the radio.
  • C Use a 10-second Timer while backgrounded. Timers don't run when suspended, and the attempt wastes energy.
  • D Play silent audio to stay alive. That misuses a background mode and fails review.

30-second answer

Save edits locally first and queue them. Sync opportunistically: when the app is active, in a BGProcessingTask that requires network (and optionally power), or with a discretionary background URLSession. Batch changes into few requests, back off on failures, and avoid timers, frequent silent pushes or continuous location to keep the app awake.

Practise saying it · 45 s. No recording, just a timer

Explain battery-friendly sync.

Say your answer out loud, then check which of these points you covered:

  • Local queue
  • Batching
  • System-scheduled work
  • Idempotent retries

Deep dive

isDiscretionary lets the system pick a good time, such as Wi-Fi and charging.

Coalesce many small edits into one request.

Respect Low Power Mode and Low Data Mode.

Make sync idempotent so retries are safe.

Common mistakes

  • Syncing every edit immediately with its own request.
  • Keeping the app awake with background audio or location tricks.

Senior take & follow-ups

Seniors design sync around the radio and the system's scheduling.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why batch?

    Show hint

    Each radio wake-up costs energy.

  2. What is a discretionary session?

    Show hint

    One where the system schedules transfers for efficiency.

Suggest a fix if something here is wrong or out of date.