Check if location services are enabled
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Checking whether location services are enabled is not the same thing as checking whether your app has permission to use location. Modern mobile platforms separate global device settings from app-specific authorization. Good code needs to understand both layers before assuming location access is available.
Check Global Location Availability on iOS
On iOS, the first global check is CLLocationManager.locationServicesEnabled(). That tells you whether location services are enabled at the device level.
That is only the first half of the decision. Your app also needs an authorization status such as authorizedWhenInUse or authorizedAlways.
An app can fail even when services are globally enabled if the user denied the app-specific permission.
If the app depends heavily on location, that usually means the UI should react differently to each state instead of treating "no location" as one generic failure. A good app can tell the user whether to open system settings, respond to a permission prompt, or simply try again later.
Check Provider State on Android
On Android, a common pattern is to ask LocationManager whether the relevant providers are enabled.
As on iOS, that does not automatically mean your app has permission. You still need runtime permission checks for fine or coarse location, depending on the feature.
The correct application logic is usually "location is usable only if the device setting allows it and the app permission allows it."
It is also worth rechecking these states when the app returns to the foreground. Users can change global location settings or app-specific permission outside your app, so a one-time check at launch is often not enough.
Design the User Flow Carefully
From a user-experience standpoint, do not just fail silently when location is unavailable. Show the difference between:
- location services disabled globally
- app permission denied
- permission not requested yet
Those states lead to different next steps. One may need a permission prompt. Another may need a deep link to system settings. Another may simply need a retry after the user turns location back on.
This distinction is especially important in apps for navigation, ride sharing, or nearby search, where location is central to the feature rather than optional.
Common Pitfalls
The most common mistake is checking only the global location-services state and forgetting app-specific permission. The app still cannot read location if the user denied access.
Another issue is treating GPS-only checks as if they covered every location mode. Depending on the platform and use case, network-based location may also matter.
People also often request permission before explaining why the feature needs it. That tends to lower acceptance and creates a worse recovery path when access is denied.
Summary
- Location availability depends on both global device settings and app-specific permission.
- On iOS, use
CLLocationManager.locationServicesEnabled()and check authorization status separately. - On Android, check the enabled location providers and the runtime permission state.
- Do not treat "services enabled" as proof that your app can actually read location.
- Handle disabled services, denied permission, and not-yet-requested permission as different user states.

