Region monitoring and geofencing

Platform & distribution Mid-level Swift 5.9+ iOS 17+ Reviewed By Alok Singh

Pick the fix

You want a reminder when the user arrives at any of 200 stores. Best approach?

Options
Hint 1 of 1

How many conditions can an app monitor?

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

Show answer

Answer: A Monitor the nearest 20 stores with CLMonitor and update the set when the user moves significantly

Correct. It stays within the limit and keeps the nearby stores covered.

Why not the others?
  • B Add 200 conditions to CLMonitor. Apps can monitor only 20 at a time.
  • C Run continuous GPS and compute distances. It drains the battery.
  • D Poll the location every minute with a Timer. Timers don't run while suspended.

30-second answer

Region monitoring tells the app when the device enters or exits a circular area, even when the app isn't running. On iOS 17+, use CLMonitor with CircularGeographicCondition and iterate its events asynchronously. An app can monitor up to 20 conditions at once, so for many places monitor the nearest ones and update the set as the user moves.

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

Explain geofencing.

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

  • CLMonitor
  • 20-condition limit
  • Always permission
  • Imprecise timing

Deep dive

Background events need Always authorization.

Very small radii trigger unreliably; test real-world behaviour on devices.

Events can be delayed by minutes.

Persisted CLMonitor conditions survive relaunch; recreate the monitor with the same name.

Common mistakes

  • Trying to monitor hundreds of regions.
  • Expecting instant, precise events.

Senior take & follow-ups

Seniors know the 20-condition limit and design around it.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you handle 200 stores?

    Show hint

    Monitor the nearest 20 and refresh the set.

  2. What permission do background events need?

    Show hint

    Always.

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