Syncing a phone app and a watch app

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

Pick the fix

Settings change on either device, and only the newest settings matter. Which API?

Options
Hint 1 of 1

Latest state, or every change?

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

Show answer

Answer: A updateApplicationContext

Correct. It keeps and delivers only the latest dictionary.

Why not the others?
  • B sendMessage. It only works while the counterpart is reachable.
  • C transferUserInfo. It delivers every queued change, which is unnecessary when only the latest matters.
  • D transferFile. Files are overkill for a small dictionary.

30-second answer

Give each side its own local store so it works alone, and sync changes when possible. With WatchConnectivity, use updateApplicationContext for the latest state (only the newest copy is kept), transferUserInfo for a queue of changes that must all arrive, transferFile for files, and sendMessage only when the counterpart is reachable. Resolve conflicts with timestamps or per-field rules, or sync both through your server or CloudKit.

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

Explain phone and watch sync.

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

  • Local store on each side
  • Transfer types
  • Conflict resolution

Deep dive

Independent watch apps can talk to the network directly.

Activate the WCSession early on both sides.

Deliveries can arrive in the background; process them quickly.

Version the sync payload.

Common mistakes

  • Using sendMessage for data that must arrive.
  • No conflict rules when both sides edit.

Senior take & follow-ups

Seniors choose the transfer type by delivery semantics and design conflict handling.

Follow-up questions

Think of your answer first, then open the hint.

  1. Which API keeps only the latest value?

    Show hint

    updateApplicationContext.

  2. Which guarantees every item?

    Show hint

    transferUserInfo.

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