The react-native-android-location-enabler package lets a React Native app display the native, Google Maps-style Android dialog that prompts users to turn on device location services when they are switched off. It wraps Android's SettingsClient API so that, instead of dumping the user into the system settings screen, your app can ask them to enable GPS or high-accuracy location in place, with a single tap, and get back a result you can act on.
This is a convenience-and-UX package, not a permissions library, and that distinction matters for both correctness and privacy. Here is how to use it well.
Enabling location vs requesting permission
There are two separate things an Android app needs before it can read a user's location, and this package only handles one of them:
- Runtime permission. The user must grant your app the
ACCESS_FINE_LOCATIONorACCESS_COARSE_LOCATIONpermission. That is a permissions API concern, handled by React Native'sPermissionsAndroidor a library likereact-native-permissions. - Location services being on. Even with permission granted, the device's location setting can be switched off system-wide. That is what react-native-android-location-enabler addresses.
Confusing the two leads to a frustrating bug: you have permission, but every location read returns nothing because services are off. You still need to prompt the user to enable them. This package makes that prompt native and in-context.
Installing and using it
Install the package:
npm i react-native-android-location-enabler
Since React Native 0.60 with autolinking, no manual native module wiring is required. The package exposes two functions you will use together:
import {
isLocationEnabled,
promptForEnableLocationIfNeeded,
} from 'react-native-android-location-enabler';
async function ensureLocationOn() {
const enabled = await isLocationEnabled();
if (enabled) return true;
try {
await promptForEnableLocationIfNeeded({
interval: 10000,
waitForAccurate: true,
});
return true;
} catch (err) {
// User declined the dialog, or it is unavailable on this device
return false;
}
}
isLocationEnabled checks the current state, and promptForEnableLocationIfNeeded shows the native dialog only when needed. Wrap the prompt in a try/catch, because the user can decline, and your app must handle "no" gracefully rather than looping the dialog.
This is Android-only, by design
The name is explicit, but it bears repeating: this is an Android-only module. iOS handles location-services enablement differently and does not offer an equivalent in-app "turn it on for me" dialog. On iOS you detect that services are disabled and guide the user to Settings yourself.
If you build cross-platform, gate the call behind a platform check so you do not call an Android-only native method on iOS:
import { Platform } from 'react-native';
if (Platform.OS === 'android') {
await ensureLocationOn();
}
A related package, react-native-location-enabler, offers similar functionality with a slightly different API; if you evaluate both, pick one and standardize on it rather than mixing them, since they cover the same ground.
Privacy and security practices that go with it
Prompting a user to switch on location is the easy part. Doing it responsibly is what keeps you out of trouble with both users and app-store review.
Prompt at the moment of need, not at launch. Ask for location to be enabled when the user taps something that clearly requires it, such as "find stores near me." A cold-start location prompt reads as data-grabbing and hurts opt-in rates.
Request the least precision you need. If your feature works with coarse location, do not demand fine GPS. Minimizing collected precision is a privacy principle and reduces your exposure if data is ever leaked.
Handle the decline path fully. A user who says no should still be able to use the parts of your app that do not need location. Do not soft-lock the experience behind an enabled GPS.
Be honest in your privacy disclosures. If you collect location, your store listing and privacy policy must say so accurately, including any third parties the data reaches.
From a supply-chain angle, this is another native-linked dependency living in your production binary. Keep it pinned, keep it current, and include it when you audit your mobile dependency tree. Mobile bundles are hard to patch after release, so an SCA tool such as Safeguard flagging a known-vulnerable package pre-build is cheaper than an emergency app update; our SCA product scans native mobile manifests, and the academy covers mobile data-privacy practices in more depth.
FAQ
What does react-native-android-location-enabler do?
It shows the native Android dialog that asks the user to turn on location services when they are disabled, using Android's SettingsClient. It lets your app enable GPS or high-accuracy mode in-context instead of sending the user to the system settings screen.
Is this the same as requesting location permission?
No. This package enables the device's location services; it does not grant your app permission to read location. You still need runtime permission via PermissionsAndroid or react-native-permissions. Both must be satisfied before location reads succeed.
Does react-native-android-location-enabler work on iOS?
No, it is Android-only. iOS does not provide an equivalent in-app dialog to enable location services. On iOS, detect that services are off and direct the user to Settings. Gate the call behind a Platform.OS === 'android' check.
When should I prompt the user to enable location?
At the point a feature actually needs it, not at app launch. Contextual prompts convert better and read as less invasive. Always handle the case where the user declines, and never block unrelated functionality behind enabled location services.