native-geo-location
v2.0.1
Published
Native geolocation with Android location toggle and iOS status check
Maintainers
Readme
Native Geo Location
A Capacitor plugin to get current device location and check if location services are enabled, for both Android and iOS.
📦 Installation
npm install native-geo-location
npx cap sync⚙️ Configuration
iOS
In your Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location for attendance check-in</string>🚀 Usage
import { NativeGeoLocation } from 'native-geo-location';
const getLocation = async () => {
const status = await NativeGeoLocation.turnLocationOn();
if (status.enabled) {
const pos = await NativeGeoLocation.getCurrentLocation();
console.log('Latitude:', pos.latitude);
console.log('Longitude:', pos.longitude);
}
};📘 API
getCurrentLocation()
Returns:
Promise<{
latitude: number;
longitude: number;
accuracy: number;
altitude?: number;
speed?: number;
bearing?: number;
}>;turnLocationOn()
Checks if location is enabled. On Android, opens settings if disabled.
Returns:
Promise<{ enabled: boolean }>;🧑 Author
Burhanuddin Hamzabhai
🦩 License
MIT
