Book a free call

How to Add Geolocation to a Mobile App

Geolocation lets an app find the user, show nearby places and track movement, but it needs permissions and privacy care. Here is how to add it properly.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How to Add Geolocation to a Mobile App
On this page

Short answer

Geolocation in a mobile app uses the phone's GPS, Wi-Fi and mobile networks to work out where the user is, then uses that position for features like nearby search, delivery tracking and geofencing. Adding it means asking permission at the right moment, choosing the right accuracy for each feature, and handling privacy and battery use so the app stays trusted and fast.

What is geolocation in a mobile app?

Geolocation in a mobile app is the ability to work out where the phone is, usually as a latitude and longitude, and to use that position inside the app. The phone combines signals from GPS satellites, nearby Wi-Fi networks and mobile towers to estimate its position, and the app asks the operating system for that position when it needs it.

The position can be a single snapshot, such as when a user searches for places nearby, or a live stream, such as when a delivery rider is tracked on a map. The app can also act on position without showing a map at all, for example by sending a notification when the user enters a defined area, which is called geofencing.

Geolocation is a feature, not a product on its own. It powers delivery tracking, ride hailing, store finders, fitness tracking, check-ins and many other features, and the design choices around accuracy, permission and battery use decide whether users trust it. For the cost side, see the cost of location tracking apps.

Which location features do apps use most?

The location features apps use most are nearby search, live tracking, geofencing and check-ins, and each one needs a different level of accuracy. Nearby search only needs a rough position, so a city-level fix is enough, while turn-by-turn navigation needs metre-level accuracy and constant updates.

Live tracking is the most demanding feature, because it needs frequent updates over a long period. A delivery app tracks a rider for the whole trip, which means the app must keep getting positions in the background without draining the battery. Geofencing is lighter: the system watches for entry and exit from a defined area and wakes the app only when something happens.

FeatureAccuracy neededHow often it updates
Nearby searchRough, city levelOnce per search
Store finderNeighbourhood levelOnce per search
Live trackingMetre levelEvery few seconds
NavigationMetre levelContinuous
GeofencingArea levelOn entry and exit only
Check-inPlace levelWhen the user taps

Pick the accuracy each feature actually needs. Asking for the most precise position for every feature wastes battery and makes users suspicious, while too little accuracy makes navigation useless. Match the request to the job. The feature set usually sits inside a wider mobile app build.

How do you get the user's location?

You get the user's location by asking the phone's operating system, which combines GPS, Wi-Fi and mobile network signals into a single position. GPS is the most accurate outdoors, Wi-Fi positioning works well in cities and indoors, and mobile towers give a rough fix when neither is available.

On both iOS and Android, the app requests a position through the system location service, which returns a latitude, longitude, accuracy radius and timestamp. The app should check the timestamp and the accuracy radius before trusting the fix: a position from an hour ago, or one with a 500-metre radius, is not good enough for navigation.

For live tracking, the app asks for updates at an interval that fits the feature, such as every 5 seconds for a moving rider, and stops asking when the trip ends. For a one-off search, a single request is enough. The operating system may also return a cached position first, so the app should wait for a fresh fix before showing results that depend on it.

How do you handle permissions and privacy?

You handle permissions and privacy by asking at the moment the user needs the feature, explaining why, and offering a clear choice. Asking for location the first time the app opens, before the user has seen any value, is the fastest way to get a refusal that is hard to reverse.

The right moment is when the user taps a feature that needs location, such as finding nearby stores. Show a short explanation first, then the system prompt. If the user says no, the app should still work, with a manual option such as typing an address, rather than blocking them entirely.

Privacy rules add more requirements. On both platforms, background location needs a separate permission and a clear justification, and the app must explain what it collects, why, and how long it keeps it. Location history should be kept only as long as the feature needs it, and it should never be shared without the user's knowledge. A clear privacy notice in the app store listing helps users decide to install in the first place.

How do you add geofencing and background updates?

You add geofencing by defining an area, usually a circle around a point, and asking the system to notify the app when the phone enters or leaves it. The operating system watches the area in an efficient way, so the app does not need to keep checking the position itself, which saves battery.

Background updates are harder, because both platforms limit what an app can do while it is not on screen. An app that tracks a delivery rider needs a foreground service with a visible notification, so the user knows tracking is active. Without that, the system will pause updates and the tracking will go stale.

Battery use is the main trade-off. Frequent, high-accuracy updates drain the battery fast, so the app should lower the update rate when the user is still, and raise it only while moving. Test on real devices over a full day, because a feature that works in a 10-minute test can still drain a battery by evening.

How do you add geolocation in 6 steps?

You add geolocation by choosing the features first, then wiring up permissions, then the position requests, then the map and the edge cases. Building the map first and the permissions last is the usual way to end up with a feature users refuse.

  1. List the features. Decide which features need location and what accuracy each one needs.
  2. Design the permission flow. Decide when to ask, what to explain, and what the app does if the user says no.
  3. Request positions. Use the system location service, check the timestamp and accuracy radius, and handle a missing or stale fix.
  4. Show it on a map. Add a map view, place markers, and handle the case where the map fails to load.
  5. Add geofencing or tracking. If the feature needs it, add area monitoring or background updates with a visible notification.
  6. Test in the real world. Walk, drive and go indoors with the app, and check battery use over a full day.

Keep a fallback for every location feature. If the user refuses permission, or the signal is lost, the app should still let them search, type an address or continue without live tracking. Location is one part of the wider design; see how to design a mobile app for the rest.

Example (hypothetical): a delivery app adds live rider tracking

Example (hypothetical): a delivery app with 20 riders adds live tracking so customers can watch their order on a map. Each rider's phone sends a position every 5 seconds during a trip, and the average trip lasts 30 minutes, so each trip produces 360 updates.

With 20 riders each doing 8 trips a day, the app handles 20 × 8 × 360 = 57,600 updates a day. The team sets the update rate to drop to once a minute when a rider is still for more than 2 minutes, which cuts the total by about a third, to roughly 38,000 updates a day.

Battery testing shows a rider's phone loses about 12 percent of charge per hour while tracking, against 4 percent without it. The team accepts that, because riders charge their phones between shifts, but adds a warning when the battery falls below 20 percent. Support tickets asking where an order is fall from 40 a day to 9, because customers can see the rider on the map.

What are the common mistakes?

The most common geolocation mistakes are asking for permission too early, requesting more accuracy than the feature needs, and forgetting the fallback when location is unavailable. Each one costs users and trust.

  • Asking on first launch. A permission request before the user sees any value usually gets refused; ask when the feature is used.
  • Maximum accuracy everywhere. Metre-level tracking for a nearby search wastes battery and looks intrusive; match accuracy to the job.
  • No fallback. If the user refuses, or the signal is lost, the app should still work with a typed address.
  • Silent background tracking. Tracking without a visible notification breaks platform rules and user trust; show that tracking is active.
  • Trusting stale positions. A cached fix from an hour ago can place the user in the wrong city; check the timestamp and accuracy radius.
  • Ignoring battery use. A feature that drains the battery by evening will be switched off; test over a full day.

Key takeaways

  • Geolocation combines GPS, Wi-Fi and mobile signals into a position the app can use
  • Match accuracy to the feature: rough for search, metre-level for navigation and tracking
  • Ask permission when the feature is used, explain why, and offer a fallback
  • Geofencing is light on battery; background tracking needs a visible notification
  • Check timestamps and accuracy before trusting a fix, and test battery use over a full day

Frequently asked questions

How accurate is phone geolocation?

Outdoors with a clear sky, GPS can be accurate to a few metres. In cities, Wi-Fi positioning gives tens of metres, and mobile towers give hundreds of metres. Indoors, accuracy drops sharply. Always check the accuracy radius the system reports before trusting a fix.

Does geolocation drain the battery?

It can, especially with frequent high-accuracy updates. The drain depends on how often the app asks for a position and whether the screen is on. Lowering the update rate when the user is still, and using geofencing instead of constant tracking, keeps battery use down.

What is geofencing?

Geofencing is a virtual boundary around a place, usually a circle on a map. The phone notifies the app when it enters or leaves the area, without the app having to check the position constantly. It is used for arrival alerts, store offers and check-ins.

Do I need a map to use geolocation?

No. Many features use position without showing a map, such as sorting a list by distance, sending a notification on arrival, or recording where a photo was taken. A map is only needed when the user has to see the position.

Can an app track location in the background?

Yes, but both iOS and Android require a separate background permission, a clear justification, and usually a visible notification while tracking is active. The app must explain what it collects and why, and stop tracking when the task ends.

What should the app do if the user refuses location permission?

It should still work. Offer a manual fallback such as typing an address or choosing a place from a list, and let the user turn location on later from settings. Blocking the whole app over a refused permission is a quick way to lose users.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: software products in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Adding location features to your app? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Mobile App Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call