Skip to content
Lucent
SEARCH LUCENT

Search guides, APIs, and examples.

GitHub

Very early and experimental. The language, the generated native code and every package API change without notice. Do not use Lucent in production.

7. Ask for the location permission

The permission prompt, the Info.plist entry, and Android permissions added for you.

src/location.lucent.ts
// Managers deliver to the thread that made them: made on the main thread, kept here.
const managers = new Map<number, CLLocationManager>();
// Kept while the permission prompt is on screen.
let prompter: CLLocationManager | null = null;
// --- Android -----------------------------------------------------------------
function fromLocation(location: Location): Fix {
…
let nextId = 1;
/** Shows the system's permission prompt on iOS. Android asks from JavaScript, with PermissionsAndroid. */
export async function requestPermission(): Promise<void> {
if (PLATFORM === "ios") {
await main(() => {
prompter = new CLLocationManager();
prompter.requestWhenInUseAuthorization();
});
}
}
/** The last position the device knows, without waiting for a new one. */
export async function lastFix(): Promise<Fix | null> {
if (PLATFORM === "ios") {

requestPermission shows the system's prompt. iOS shows it only if the app says why it needs the location, in Info.plist:

app.json
{
"expo": {
"ios": {
"infoPlist": {
"NSLocationWhenInUseUsageDescription": "Trip Tracker records your route while you track a trip."
}
}
}
}

There's nothing to add to the manifest. The SDK marks requestLocationUpdates with the location permissions it needs, and lucent build adds them to the native package's manifest, which Android merges into the app's.

Asking at run time is still up to the app: App.tsx does it with PermissionsAndroid, before watch.

Rebuild the app, since Info.plist changed. It asks for the location, then tracks the trip.