@sigx/lynx-location
v0.9.1
Published
Location services for sigx-lynx
Maintainers
Readme
@sigx/lynx-location
GPS / network location for sigx-lynx. CLLocationManager on iOS, FusedLocationProviderClient on Android.
📚 Documentation
Full guides, API reference and live examples → https://sigx.dev/lynx/modules/location/overview/
Install
pnpm add @sigx/lynx-locationsigx prebuild auto-discovers the package, links the native module, adds the iOS usage descriptions:
NSLocationWhenInUseUsageDescriptionNSLocationAlwaysAndWhenInUseUsageDescription…and the Android permissions:ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATIONOn Android the runtime permission prompt comes from@sigx/lynx-permissions, a dependency of this package — the auto-linker pulls it in, nothing to install.
Usage
import { Location } from '@sigx/lynx-location';
const { status } = await Location.requestPermission();
if (status === 'granted') {
const loc = await Location.getCurrentPosition({ accuracy: 'high', timeout: 10000 });
console.log(loc.latitude, loc.longitude, loc.accuracy);
}API
| Method | Notes |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| getCurrentPosition(options?: LocationOptions): Promise<LocationResult> | One-shot fix. Throws on timeout or denied. |
| requestPermission(): Promise<PermissionResponse> | Shows the OS permission dialog if needed. |
| getPermissionStatus(): Promise<PermissionResponse> | Read-only check — no prompt. |
| isAvailable(): boolean | Whether the native module is registered in the current build. |
interface LocationOptions {
accuracy?: 'high' | 'balanced' | 'low'; // default: 'balanced'
timeout?: number; // ms; default platform-specific
}
interface LocationResult {
latitude: number;
longitude: number;
altitude: number | null;
accuracy: number; // meters
speed: number | null; // m/s
heading: number | null; // degrees
timestamp: number; // epoch ms
}Gotchas
- Background location isn't supported here. This module is
WhenInUse-only; if you needAlwaysaccess (geofencing, background tracking), the native side needs additional setup not in this package. - iOS simulator location — set a fake location in the simulator's Features → Location menu, otherwise
getCurrentPosition()hangs until timeout. - Accuracy is a hint.
'high'requestskCLLocationAccuracyBest/Priority.HIGH_ACCURACY. Actual returnedaccuracy(meters) reflects what the device managed.
