How a geofence is defined
A geofence marks a place of interest. On Android, you give a latitude and a longitude, then a radius; together they define a circular area, or fence, around the location. Apple’s Core Location works the same way with a circular condition: a centre coordinate and a radius that defines its boundary. Apple calls the feature condition monitoring, also known as geofencing, and gives the Reminders app as an example, which triggers reminders when the user arrives at or leaves a place.
Android lets an app ask for three kinds of events for each geofence:
- Enter, when the device moves inside the fence.
- Exit, when it moves out.
- Dwell, when it stays inside for a set time, called the loitering delay.
A geofence can also have an expiration, after which Android removes it automatically.
Both platforms cap how many an app can hold. Android allows 100 active geofences per app, per device user. Apple prevents any single app from monitoring more than 20 conditions of any type at the same time, because conditions are shared resources that rely on specific hardware.
Who does the watching
The app does not poll the location itself. The operating system watches the fences and wakes the app when something changes.
On iOS, the system monitors regions and wakes the app as conditions change, and if the app is not running, the system tries to launch it. Monitoring continues until the app stops it or the device reboots, and after a reboot it can only happen once the device has been unlocked. On macOS, monitoring works only while the app is running and the system is awake.
On Android, registered geofences live in a Google Play services process. The system restores them after a Play services upgrade or restart, but the app must register them again after a reboot, a reinstall, a data clear, or a GEOFENCE_NOT_AVAILABLE alert.
How precise and how fast
A geofence is only as good as the location behind it. Android’s guide says that on most devices the geofence service uses only network location for triggering, because it uses much less power, gives locations faster and is available indoors. How do phones find their location without GPS? explains where network location comes from.
That shapes Android’s advice on size:
- For best results, set the minimum radius between 100 and 150 metres.
- When Wi-Fi is available, location accuracy is usually between 20 and 50 metres.
- When indoor location is available, accuracy can be as small as 5 metres.
- Without Wi-Fi, for example when driving in rural areas, accuracy can be as large as several hundred metres to several kilometres.
Alerts are not instant. Android says the latency is usually less than 2 minutes, and about 2 to 3 minutes on average when background location limits apply. It recommends the dwell transition to avoid floods of alerts from briefly driving past a fence.
Smaller zones with beacons
For zones inside a building, Bluetooth beacons can play the part of the fence. Apple’s iBeacon region monitoring listens for nearby beacons and tells an app when the device enters or leaves a beacon region, and if the app is not running, the system tries to launch it. What is a BLE beacon? covers how that works, and indoor positioning covers methods that place a device more precisely inside a building.
Permissions and privacy
Geofencing means watching location in the background, and the platforms treat it that way. On Android, an app needs ACCESS_FINE_LOCATION, plus ACCESS_BACKGROUND_LOCATION if it targets Android 10 (API level 29) or higher. Android’s permission guide lists using the Geofencing API as a reason an app requires background location access, and notes that Google Play restricts background location to apps that need it for core features. The geofencing guide asks developers to explain clearly to users why the app needs this access.
A list of geofence events is itself a location record: it says when someone arrived at and left a set of places. What can a location record reveal? covers why that deserves care.
What a geofence cannot prove
A geofence trusts the location the device reports. If the position is wrong, from poor signal, or deliberately faked through GPS spoofing, the event is wrong too, and How is GPS spoofing detected? covers the defences. A late or missed alert is also possible, as Android’s troubleshooting notes on latency and network connectivity make clear.
That makes geofencing a good fit for reminders, arrival notices and convenience features, and a weak basis on its own for decisions with real value, such as access, payments or attendance. Where someone other than the device needs to trust a location, proof of location is a separate problem.