This plugin lets the standard navigator.geolocation code of your website work inside your app. There's no new API to learn: the code you already use in a browser keeps running. The plugin declares the location permissions, which the app can't use without.
Platforms
Included- Android
- iOS — with the native navigation (Shell V2)
Used by the native builds: Android Build (Native), Android TV and iOS. The Android Build (Web) does not read these settings.
Set it up
Add the plugin
In your project's plugin library, add Location, then launch a new build.
Ask at the right moment
The system prompt appears the first time your site asks for a position. Call it from a button, after explaining why.
Declare it in the stores
Location counts as personal data. Mention it in Data safety on Google Play and App Privacy on the App Store.
Code
navigator.geolocation.getCurrentPosition(
(position) => {
const { latitude, longitude } = position.coords;
showStoresNear(latitude, longitude);
},
(error) => showManualSearch(error.message),
{ enableHighAccuracy: true, timeout: 10000 },
);What it adds to your app
| System | Added | Scope |
|---|---|---|
| Android | ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION | While the app is open |
| iOS | NSLocationWhenInUseUsageDescription | While the app is open |
Location works while the app is open. Background tracking isn't part of this plugin.
On iOS, Location needs native navigation (Shell V2). Without the plugin, these permissions aren't declared and your site's request fails.
Prompt for AI builders
Prompt for Lovable, Bolt or Base44
On [PAGE], add a button that says why I need the location, then calls navigator.geolocation.getCurrentPosition. Handle a refusal or an error by showing a manual search. Never ask for the location when the page loads. Use a timeout of 10 seconds.
Replace the value in [BRACKETS].