0.1.2 • Published 2 weeks ago
capacitor-enable-gps-plugin
Licence
MIT
Version
0.1.2
Deps
0
Size
13 kB
Vulns
0
Weekly
0
capacitor-enable-gps-plugin
Capacitor plugin for asking Android users to enable GPS/location services.
The Android implementation uses Google Play Services SettingsClient to show the native location settings resolution dialog when possible. If the dialog cannot be shown, it opens the Android location settings screen and resolves with the current enabled state when the user returns.
Install
npm install ./capacitor-enable-gps-plugin
npx cap sync android
Usage
import { EnableGps } from 'capacitor-enable-gps-plugin';
const current = await EnableGps.isEnabled();
if (!current.enabled) {
const result = await EnableGps.requestEnable({
highAccuracy: true,
alwaysShow: true,
});
console.log('Location enabled:', result.enabled);
}
API
isEnabled() => Promise<{ enabled: boolean }>
requestEnable(options?: {
highAccuracy?: boolean;
alwaysShow?: boolean;
}) => Promise<{ enabled: boolean }>
Notes
- Android only: iOS does not provide the same app-triggered GPS enable dialog.
- This plugin checks whether either the GPS or network location provider is enabled.
- Android permissions are declared in the plugin manifest, but your app should still request runtime location permission separately before reading location.