robius-location
A Rust library to access system-provided location/GPS data across Linux, Android, iOS, macOS, and Windows.
Usage on Linux
Linux picks one of two paths automatically, and needs no setup from you:
- XDG Desktop Portal Location API (v1), always preferred. Works sandboxed or not, and the desktop handles the permission prompt.
- GeoClue directly, only if the session bus, portal, or Location interface is missing at startup.
- Never used after a portal denial, and never for Flatpak/Snap apps.
There's no C library or -dev package to link against. You just need a running GeoClue service,
which is already handled by the majority of distros.
- If you ship a
.deb/.rpm, add a dependency ongeoclue-2.0(Debian/Ubuntu),geoclue2(Fedora/RHEL), orgeoclue(Arch/Alpine). Flatpaks don't need that, just use the host portal.
Usage on iOS
To use this crate on iOS, you must add the following to your app's Info.plist:
NSLocationAlwaysAndWhenInUseUsageDescription
Insert your usage description here.
NSLocationWhenInUseUsageDescription
Insert your usage description here.
NSLocationUsageDescription
Insert your usage description here.
NSLocationDefaultAccuracyReduced
Note that the last NSLocationDefaultAccuracyReduced key isn't required unless you always need fine-grained location detail.
Usage on Android
To use this crate on Android, you must add the following to your app's AndroidManifest.xml:
<!-- Always include this permission -->
<!-- Include only if your app benefits from precise location access. -->
As specified in the Android documentation.
Note that these go in the manifest key section, not the application section.
Minimum API level
The minimum supported Android API level is 26 (Android 8.0): the bundled Java helper is loaded via
InMemoryDexClassLoader, which requires API 26. Newer location APIs (e.g. getCurrentLocation) are used only
when the device supports them, with a fallback for older versions, so set minSdk to at least 26 in your app.