Get started
Introduction
Installation
Your first app
Tutorials
Fission tutorials
Request Android location permissions in a Rust app
Core concepts
Components
State and effects
Protected routes
Server-side rendering
Styling
Testing
Deployment
Reference
API reference
Cookbook
Fission 0.16.0
Documentation version
Read the changelog →

Request Android location permissions in a Rust app

Learn how to request Android location permissions in Rust with Fission, including approximate access, denial, and recovery.
Android

What you will build

Let a Nightjar courier record a handoff at a named stop, then attach a one-time pin only when location is useful.
Keep a delivery handoff usable with its named stop and notes when location is unavailable
Request foreground location only after the driver chooses to add a pin
Refresh permission state after the Android prompt or a change in system settings
Treat approximate location as useful and show the accuracy returned by Android
A named delivery stop and a location pin answer different questions. The stop identifies where a handoff was intended to happen; the pin records where the device could place it at a particular time, with a particular accuracy. Treating the pin as the only location would make an otherwise useful handoff depend on a permission decision or a GPS signal.
Here, a Nightjar courier keeps the stop name and handoff notes in an in-memory draft, then chooses whether to attach a pin. Declining location must not discard that draft. This screen does not submit a delivery record, infer arrival from coordinates or track a driver in the background.
We will request foreground location only when the driver chooses to add the optional pin. Android may grant approximate access even when the app asks for precise access, so the screen shows the returned accuracy and lets the driver decide whether the point is useful. There is no background tracking in this flow.
Start from a new project (optional)

Create the Android project

Complete the Android SDK and NDK setup and either boot an emulator or connect a phone. Then create the shared Rust app and declare geolocation. The CLI updates the generated Android project so it declares the capability’s platform permissions.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"Create the project","value":"create-the-project"},{"index":1,"label":"Files used in this guide","value":"files-used-in-this-guide"}]}
{"id":"fission-tabs-1","index":0,"label":"Create the project","value":"create-the-project"}
cargo install cargo-fission
fission init nightjar-handoff
cd nightjar-handoff
cargo add serde_yaml
fission add-target android --project-dir .
fission add-capability geolocation --project-dir .
{"id":"fission-tabs-1","index":1,"label":"Files used in this guide","value":"files-used-in-this-guide"}
nightjar-handoff/
├── Cargo.toml
├── fission.toml
├── src/
│   ├── app.rs          # Compose screen and local handoff drafts
│   ├── app/translations.rs
│   ├── state.rs        # shared location results and reducers
│   ├── lib.rs
│   └── main.rs
└── platforms/
    └── android/        # generated Android host and packaging
{"id":"fission-tabs-1"}
Keep the screen and handoff rules in shared Rust code. Fission’s geolocation capability uses Android’s permission prompt and location provider; the shared component does not call Android APIs directly.

Run the finished example

fission run --target android --project-dir .

1. Add an optional, one-time location pin

The driver’s choice and the platform request are separate. The completion reducers read the host result from cx.input.capability_ok(...); the callback action itself carries no placeholder coordinates. This matters because binding an action containing zeroes would keep those zeroes, not turn them into a returned position. Buttons dispatch reducers; a reducer queues the geolocation effect, and another reducer stores the permission or position when the host replies. The view never opens a permission prompt or waits for a location lookup.
Android and the browser report permission differently, so the screen keeps requests, status checks, and position lookups separate. Request location access opens Android’s permission UI. The request is asynchronous, and the host may first return the state from before the driver answered. Once the prompt closes, Refresh access status reads the current state. On Android, the pin button stays unavailable until that check confirms access; a pending prompt is not approval.
The browser host reports its current state without opening a prompt. When it reports Prompt, the preview enables Add handoff pin; the browser asks for permission when the position lookup starts. The component works with both hosts while making their different permission steps clear.
Android 12 and later let people grant approximate access. When <code>precise</code> is true, Fission requests both foreground coarse and fine permissions, but Android decides what to grant. The returned <code>accuracy_meters</code> value tells the app how much confidence to place in the pin. If the location is too broad, the handoff can still keep its depot and loading-bay name.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/state.rs","value":"src-state-rs"},{"index":2,"label":"src/app/translations.rs","value":"src-app-translations-rs"},{"index":3,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":4,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"},{"index":5,"label":"src/lib.rs · Android and browser startup","value":"src-lib-rs-android-and-browser-startup"},{"index":6,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
pub mod translations;

use crate::state::*;
use fission::prelude::*;

fission_component! {
    pub DeliveryHandoffForm<DeliveryHandoffState> {
        state {
            stop_name: String = String::new(),
            handoff_notes: String = String::new(),
        }
    }
    view(form, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let access_granted = state.permission == Some(GeolocationPermission::Granted);
        let can_add_pin = may_request_position(state.permission, cfg!(target_arch = "wasm32"));
        let permission_message = state.permission_message
            .map(|message| cx.tr(message.translation_key()))
            .unwrap_or_else(|| cx.tr("handoff.permission.not_checked"));
        let location_message = state.location_message
            .map(|message| cx.tr(message.translation_key()))
            .unwrap_or_else(|| cx.tr("handoff.location.no_pin"));
    } =>
    SemanticsRegion(
        identifier: Some("nightjar-handoff-form".to_string()),
        label: Some(cx.tr("handoff.screen.label")),
        child: Scroll(
            flex_grow: 1.0,
            height: cx.view.viewport_size().height,
            child: Container(
                Column(align_items: ir_op::AlignItems::Center, children: [
                    Container(
                        Column(gap: tokens.spacing.m, children: [
                            Column(gap: tokens.spacing.xs, children: [
                                Text(cx.tr("handoff.brand"))
                                    .weight(tokens.typography.font_weight_bold),
                                Text(cx.tr("handoff.subtitle"))
                                    .color(tokens.colors.text_secondary),
                            ]),
                            Row(gap: tokens.spacing.xs, children: [
                                Button(
                                    child: Text(cx.tr("locale.english")),
                                    key: "locale-en-US",
                                    variant: if state.locale == Locale::from("en-US") { ButtonVariant::Primary } else { ButtonVariant::Outline },
                                    on_press: reduce { state.locale = Locale::from("en-US"); },
                                ).semantics_identifier("handoff.locale.en-US".to_string()),
                                Button(
                                    child: Text(cx.tr("locale.spanish")),
                                    key: "locale-es-ES",
                                    variant: if state.locale == Locale::from("es-ES") { ButtonVariant::Primary } else { ButtonVariant::Outline },
                                    on_press: reduce { state.locale = Locale::from("es-ES"); },
                                ).semantics_identifier("handoff.locale.es-ES".to_string()),
                            ]),
                            Text(cx.tr("handoff.optional_pin"))
                                .weight(tokens.typography.font_weight_bold),
                            if state.permission_busy { Spinner(motion: Some(SpinnerMotion::Default), label: Some(cx.tr("handoff.permission.checking"))) },
                            Text(permission_message)
                                .color(tokens.colors.text_secondary),
                            Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
                                Button(
                                    child: Text(if state.permission_busy {
                                        cx.tr("handoff.action.working")
                                    } else if access_granted {
                                        cx.tr("handoff.action.access_granted")
                                    } else {
                                        cx.tr("handoff.action.request_access")
                                    }),
                                    key: "request-location-access",
                                    variant: ButtonVariant::Outline,
                                    disabled: state.permission_busy || state.locating || access_granted,
                                    on_press: reduce { request_access(state, cx); },
                                )
                                .semantics_identifier("handoff.request-location-access".to_string()),
                                Button(
                                    child: Text(cx.tr("handoff.action.refresh_access")),
                                    key: "refresh-location-access",
                                    variant: ButtonVariant::Outline,
                                    disabled: state.permission_busy || state.locating,
                                    on_press: reduce { refresh_access(state, cx); },
                                )
                                .semantics_identifier("handoff.refresh-location-access".to_string()),
                            ]),
                            TextInput(
                                label: Some(cx.tr("handoff.field.stop").into()),
                                placeholder: Some(cx.tr("handoff.field.stop_placeholder").into()),
                                bind: form.stop_name,
                                helper_text: Some(cx.tr("handoff.field.stop_help").into()),
                                semantics_identifier: "handoff.stop-name".to_string(),
                            ),
                            TextInput(
                                label: Some(cx.tr("handoff.field.notes").into()),
                                placeholder: Some(cx.tr("handoff.field.notes_placeholder").into()),
                                bind: form.handoff_notes,
                                multiline: true,
                                required: true,
                                helper_text: Some(
                                    cx.tr("handoff.field.notes_help").into(),
                                ),
                                semantics_identifier: "handoff.notes".to_string(),
                            ),
                            Button(
                                child: Text(if state.locating {
                                    cx.tr("handoff.action.finding_pin")
                                } else {
                                    cx.tr("handoff.action.add_pin")
                                }),
                                key: "add-handoff-pin",
                                variant: ButtonVariant::Outline,
                                disabled: state.locating || state.permission_busy || !can_add_pin,
                                on_press: reduce { add_pin(state, cx); },
                            )
                            .semantics_identifier("handoff.add-pin".to_string()),
                            if state.locating { Spinner(motion: Some(SpinnerMotion::Default), label: Some(cx.tr("handoff.location.finding"))) },
                            Text(location_message)
                                .color(tokens.colors.text_secondary),
                            if let Some(position) = &state.position {
                                Text(cx.tr("handoff.location.coordinates")
                                    .replace("{latitude}", &format!("{:.5}", position.latitude))
                                    .replace("{longitude}", &format!("{:.5}", position.longitude))
                                    .replace("{accuracy}", &format!("{:.0}", position.accuracy_meters)))
                            },
                            Text(cx.tr("handoff.draft_note"))
                                .color(tokens.colors.text_secondary),
                        ])
                    )
                    .padding_all(tokens.spacing.l)
                    .width_length(Length::clamp(
                        Length::points(0.0),
                        Length::percent(100.0),
                        Length::points(680.0),
                    ))
                    .bg(tokens.colors.surface)
                    .border(tokens.colors.border, 1.0)
                    .border_radius(tokens.radii.medium),
                ]),
            )
            .width_length(Length::percent(100.0))
            .bg(tokens.colors.background),
        ),
    )
}
{"id":"fission-tabs-1","index":1,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;

#[derive(Debug, Default)]
pub struct DeliveryHandoffState {
    pub locale: Locale,
    pub permission: Option<GeolocationPermission>,
    pub permission_busy: bool,
    pub permission_message: Option<PermissionMessage>,
    pub locating: bool,
    pub position: Option<GeolocationPosition>,
    pub location_message: Option<LocationMessage>,
}

impl GlobalState for DeliveryHandoffState {}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PermissionMessage {
    Requesting,
    Checking,
    Granted,
    Denied,
    Prompt,
    Unsupported,
    Unknown,
    CheckFailed,
}

impl PermissionMessage {
    pub fn translation_key(self) -> &'static str {
        match self {
            Self::Requesting => "handoff.permission.requesting",
            Self::Checking => "handoff.permission.checking",
            Self::Granted => "handoff.permission.granted",
            Self::Denied => "handoff.permission.denied",
            Self::Prompt => "handoff.permission.prompt",
            Self::Unsupported => "handoff.permission.unsupported",
            Self::Unknown => "handoff.permission.unknown",
            Self::CheckFailed => "handoff.permission.check_failed",
        }
    }
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LocationMessage {
    Finding,
    Captured,
    AccessRequired,
    Denied,
    Unsupported,
    TimedOut,
    Unavailable,
    Failed,
}

impl LocationMessage {
    pub fn translation_key(self) -> &'static str {
        match self {
            Self::Finding => "handoff.location.finding",
            Self::Captured => "handoff.location.captured",
            Self::AccessRequired => "handoff.location.access_required",
            Self::Denied => "handoff.location.denied",
            Self::Unsupported => "handoff.location.unsupported",
            Self::TimedOut => "handoff.location.timeout",
            Self::Unavailable => "handoff.location.unavailable",
            Self::Failed => "handoff.location.failed",
        }
    }
}


#[fission_reducer(LocationPermissionUpdated)]
fn permission_updated(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    state.permission_busy = false;
    let permission = cx.input.capability_ok(REQUEST_GEOLOCATION_PERMISSION)
        .or_else(|| cx.input.capability_ok(GET_GEOLOCATION_PERMISSION));
    state.permission = permission;
    state.permission_message = Some(match permission {
        Some(GeolocationPermission::Granted) => PermissionMessage::Granted,
        Some(GeolocationPermission::Denied) => PermissionMessage::Denied,
        Some(GeolocationPermission::Prompt) => PermissionMessage::Prompt,
        Some(GeolocationPermission::Unsupported) => PermissionMessage::Unsupported,
        Some(GeolocationPermission::Unknown) | None => PermissionMessage::Unknown,
    });
}

#[fission_reducer(LocationPermissionFailed)]
fn permission_failed(state: &mut DeliveryHandoffState) {
    state.permission_busy = false;
    state.permission_message = Some(PermissionMessage::CheckFailed);
}

pub fn request_access(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    if state.permission_busy || state.locating { return; }
    state.permission_busy = true;
    state.permission_message = Some(PermissionMessage::Requesting);
    let ok = cx.effects.bind(LocationPermissionUpdated, reduce_with!(permission_updated));
    let err = cx.effects.bind(LocationPermissionFailed, reduce_with!(permission_failed));
    cx.effects.geolocation()
        .request_permission(GeolocationPermissionRequest { precise: true, background: false })
        .on_ok(ok).on_err(err);
}

pub fn refresh_access(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    if state.permission_busy || state.locating { return; }
    state.permission_busy = true;
    state.permission_message = Some(PermissionMessage::Checking);
    let ok = cx.effects.bind(LocationPermissionUpdated, reduce_with!(permission_updated));
    let err = cx.effects.bind(LocationPermissionFailed, reduce_with!(permission_failed));
    cx.effects.geolocation().permission().on_ok(ok).on_err(err);
}

#[fission_reducer(HandoffPinCaptured)]
fn pin_captured(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    state.locating = false;
    if let Some(position) = cx.input.capability_ok(GET_CURRENT_POSITION) {
        state.position = Some(position);
        state.location_message = Some(LocationMessage::Captured);
    } else {
        state.location_message = Some(LocationMessage::Failed);
    }
}

#[fission_reducer(HandoffPinFailed)]
fn pin_failed(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    state.locating = false;
    let error = cx.input.capability_error(GET_CURRENT_POSITION);
    let code = error.as_ref().map(|error| error.code.as_str()).unwrap_or("");
    if code == "permission_denied" {
        state.permission = Some(GeolocationPermission::Denied);
        state.permission_message = Some(PermissionMessage::Denied);
    }
    state.location_message = Some(match code {
        "permission_denied" => LocationMessage::Denied,
        "unsupported" => LocationMessage::Unsupported,
        "timeout" => LocationMessage::TimedOut,
        "position_unavailable" | "unavailable" => LocationMessage::Unavailable,
        _ => LocationMessage::Failed,
    });
}

pub fn may_request_position(permission: Option<GeolocationPermission>, browser: bool) -> bool {
    permission == Some(GeolocationPermission::Granted)
        || (browser && permission == Some(GeolocationPermission::Prompt))
}

pub fn add_pin(state: &mut DeliveryHandoffState, cx: &mut ReducerContext<DeliveryHandoffState>) {
    if state.locating || state.permission_busy { return; }
    if !may_request_position(state.permission, cfg!(target_arch = "wasm32")) {
        state.location_message = Some(LocationMessage::AccessRequired);
        return;
    }
    state.locating = true;
    state.location_message = Some(LocationMessage::Finding);
    let ok = cx.effects.bind(HandoffPinCaptured, reduce_with!(pin_captured));
    let err = cx.effects.bind(HandoffPinFailed, reduce_with!(pin_failed));
    cx.effects.geolocation()
        .current_position(GeolocationPositionRequest {
            high_accuracy: true, timeout_ms: Some(10_000), maximum_age_ms: Some(30_000),
        }).on_ok(ok).on_err(err);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn only_the_browser_may_prompt_as_part_of_position_lookup() {
        assert!(!may_request_position(Some(GeolocationPermission::Prompt), false));
        assert!(may_request_position(Some(GeolocationPermission::Prompt), true));
    }
    #[test]
    fn absent_or_denied_access_never_enables_a_position_request() {
        for permission in [None, Some(GeolocationPermission::Denied), Some(GeolocationPermission::Unknown),
                           Some(GeolocationPermission::Unsupported)] {
            assert!(!may_request_position(permission, false));
            assert!(!may_request_position(permission, true));
        }
        assert!(may_request_position(Some(GeolocationPermission::Granted), false));
    }
}
{"id":"fission-tabs-1","index":2,"label":"src/app/translations.rs","value":"src-app-translations-rs"}
use std::collections::HashMap;

use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::Env;

const SOURCES: [(&str, &str); 2] = [
    ("en-US", include_str!("../../i18n/en-US.yaml")),
    ("es-ES", include_str!("../../i18n/es-ES.yaml")),
];

pub fn create_env() -> Env {
    let mut env = Env::default();
    env.locale = Locale::from("en-US");
    for (locale, source) in SOURCES {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid handoff translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(locale),
            messages,
        });
    }
    env
}
{"id":"fission-tabs-1","index":3,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
locale.english: "English"
locale.spanish: "Spanish"
handoff.screen.label: "Nightjar Couriers delivery handoff"
handoff.brand: "Nightjar Couriers"
handoff.subtitle: "Delivery handoff · Harbor Street depot"
handoff.optional_pin: "The location pin is optional"
handoff.permission.not_checked: "Location has not been checked. Request access only when this handoff needs a pin."
handoff.permission.requesting: "Requesting foreground location access…"
handoff.permission.checking: "Checking the current location access…"
handoff.permission.granted: "Location access is granted. Add a pin only if this handoff needs one."
handoff.permission.denied: "Location is not currently granted. Refresh after the Android prompt or change access in system settings. You can continue without a pin."
handoff.permission.prompt: "No location choice has been made. Answer the Android prompt, then refresh. The browser asks when you add a pin."
handoff.permission.unsupported: "This host cannot provide location. The stop and handoff notes remain available."
handoff.permission.unknown: "The host could not determine location access. Refresh the status or continue without a pin."
handoff.permission.check_failed: "The host could not check location access. Continue without a pin or try again."
handoff.location.no_pin: "No GPS pin is attached. The named stop remains the handoff location."
handoff.location.finding: "Finding a position for this handoff…"
handoff.location.captured: "A location pin was returned. Review its reported accuracy before using it."
handoff.location.access_required: "Request access and refresh its status before adding a pin. The form remains available without it."
handoff.location.denied: "Location was not granted. Refresh access after the prompt, or continue without a pin."
handoff.location.unsupported: "This device cannot provide a location pin. Keep the named stop and handoff notes."
handoff.location.timeout: "The phone did not find a position in time. Try again or continue without a pin."
handoff.location.unavailable: "The location provider has no position right now. Check location services or continue without a pin."
handoff.location.failed: "The provider could not add a pin. The stop and notes are unchanged."
handoff.location.coordinates: "Map pin: {latitude}, {longitude} · about {accuracy} m accuracy"
handoff.action.working: "Working…"
handoff.action.access_granted: "Location access granted"
handoff.action.request_access: "Request location access"
handoff.action.refresh_access: "Refresh access status"
handoff.action.finding_pin: "Finding handoff pin…"
handoff.action.add_pin: "Add handoff pin"
handoff.field.stop: "Delivery stop"
handoff.field.stop_placeholder: "For example, Harbor Street depot · Bay 4"
handoff.field.stop_help: "Keep a named stop so the handoff still makes sense without GPS."
handoff.field.notes: "Handoff notes"
handoff.field.notes_placeholder: "Who received the package? What should the next courier know?"
handoff.field.notes_help: "Record who received the package or what the next courier should know."
handoff.draft_note: "This screen demonstrates the location capability. It does not persist or submit the handoff."
{"id":"fission-tabs-1","index":4,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
locale.english: "Inglés"
locale.spanish: "Español"
handoff.screen.label: "Entrega de Nightjar Couriers"
handoff.brand: "Nightjar Couriers"
handoff.subtitle: "Entrega · Depósito de Harbor Street"
handoff.optional_pin: "La ubicación es opcional"
handoff.permission.not_checked: "Aún no se comprobó la ubicación. Solicita acceso solo si esta entrega necesita un punto."
handoff.permission.requesting: "Solicitando acceso a la ubicación en primer plano…"
handoff.permission.checking: "Comprobando el acceso actual a la ubicación…"
handoff.permission.granted: "El acceso a la ubicación está concedido. Añade un punto solo si esta entrega lo necesita."
handoff.permission.denied: "El acceso a la ubicación no está concedido. Actualiza el estado tras el diálogo de Android o cambia el acceso en los ajustes. Puedes continuar sin un punto."
handoff.permission.prompt: "Aún no se eligió una opción. Responde al diálogo de Android y actualiza el estado. El navegador pregunta al añadir un punto."
handoff.permission.unsupported: "Este host no puede proporcionar la ubicación. El punto de entrega y las notas siguen disponibles."
handoff.permission.unknown: "El host no pudo determinar el acceso a la ubicación. Actualiza el estado o continúa sin un punto."
handoff.permission.check_failed: "El host no pudo comprobar el acceso a la ubicación. Continúa sin un punto o vuelve a intentarlo."
handoff.location.no_pin: "No hay coordenadas adjuntas. El lugar indicado sigue siendo el punto de entrega."
handoff.location.finding: "Buscando la ubicación de esta entrega…"
handoff.location.captured: "Se recibió un punto de ubicación. Comprueba su precisión antes de usarlo."
handoff.location.access_required: "Solicita acceso y actualiza el estado antes de añadir un punto. El formulario sigue disponible sin él."
handoff.location.denied: "No se concedió la ubicación. Actualiza el acceso tras el diálogo o continúa sin un punto."
handoff.location.unsupported: "Este dispositivo no puede proporcionar la ubicación. Conserva el lugar y las notas de entrega."
handoff.location.timeout: "El teléfono no encontró una ubicación a tiempo. Vuelve a intentarlo o continúa sin un punto."
handoff.location.unavailable: "El proveedor no tiene una ubicación disponible ahora. Comprueba los servicios o continúa sin un punto."
handoff.location.failed: "El proveedor no pudo añadir el punto. El lugar y las notas no cambian."
handoff.location.coordinates: "Punto: {latitude}, {longitude} · precisión aproximada de {accuracy} m"
handoff.action.working: "En curso…"
handoff.action.access_granted: "Acceso a la ubicación concedido"
handoff.action.request_access: "Solicitar acceso a la ubicación"
handoff.action.refresh_access: "Actualizar el estado del acceso"
handoff.action.finding_pin: "Buscando el punto de entrega…"
handoff.action.add_pin: "Añadir punto de ubicación"
handoff.field.stop: "Punto de entrega"
handoff.field.stop_placeholder: "Por ejemplo, depósito de Harbor Street · Muelle 4"
handoff.field.stop_help: "Indica un lugar para que la entrega siga siendo clara sin GPS."
handoff.field.notes: "Notas de entrega"
handoff.field.notes_placeholder: "¿Quién recibió el paquete? ¿Qué debe saber el siguiente repartidor?"
handoff.field.notes_help: "Indica quién recibió el paquete o qué debe saber el siguiente repartidor."
handoff.draft_note: "Esta pantalla muestra la capacidad de ubicación. No guarda ni envía la entrega."
{"id":"fission-tabs-1","index":5,"label":"src/lib.rs · Android and browser startup","value":"src-lib-rs-android-and-browser-startup"}
mod app;
mod state;

use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<state::DeliveryHandoffState, _>::new(app::DeliveryHandoffForm::new())
        .with_env(app::translations::create_env())
        .with_sync_env(|state, env| env.locale = state.locale.clone())
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<state::DeliveryHandoffState, app::DeliveryHandoffForm> {
    let app = MobileApp::<state::DeliveryHandoffState, _>::new(app::DeliveryHandoffForm::new())
        .with_env(app::translations::create_env())
        .with_sync_env(|state, env| env.locale = state.locale.clone())
        .with_title("Delivery handoff");
    #[cfg(target_os = "android")]
    let app = app.with_test_control_port(48761);
    app
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = mobile_app().run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::DeliveryHandoffState, _>::new(app::DeliveryHandoffForm::new())
        .with_env(app::translations::create_env())
        .with_sync_env(|state, env| env.locale = state.locale.clone())
        .with_title("Delivery handoff")
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod state;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::DeliveryHandoffState, _>::new(app::DeliveryHandoffForm::new())
        .with_env(app::translations::create_env())
        .with_sync_env(|state, env| env.locale = state.locale.clone())
        .with_title("Nightjar Couriers handoff")
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1"}
The position request asks for a fresh, high-accuracy reading, with a ten-second timeout and a short cache age. Those are preferences, not guarantees: the device may return an older or less precise result. That is why the screen shows the reported accuracy and leaves the depot name and notes alone if lookup fails.

Verify the Android permission choices

Run the generated app on an emulator and test each choice from a known permission state. Reset the app’s location permission in Android Settings between runs to see the first-use prompt again.
<Tabs> <TabItem label="Run on Android"> ```sh fission doctor android --project-dir . fission run --target android --project-dir . ``` </TabItem> <TabItem label="Check permission behavior"> ```text 1. On first use, request location access from the handoff form. 2. Choose precise access. Refresh the status, add a pin, and check the reported accuracy. 3. Reset the permission, choose approximate access, refresh, and add a pin. 4. Reset once more and deny access. Confirm the stop and notes remain in the current screen state. 5. Turn Android location services off and confirm the app offers the no-pin path without clearing the draft. ``` </TabItem> </Tabs>
Approximate access is still permission granted. Don’t report it as a failure or silently ask for more. If the pin is not useful at that accuracy, the driver can keep the named stop and complete the handoff. This guide only requests foreground access; it does not add <code>ACCESS_BACKGROUND_LOCATION</code>.
For platform behavior, see Android’s runtime location permission guide and approximate location guidance. For Fission’s portable provider contract, see the Geolocation capability guide and the Geolocation reference.
In the browser preview, refresh access first. If the browser reports Prompt, select Add handoff pin and respond to its location prompt. On Android, select Request location access, choose precise or approximate access in the system UI, then press Refresh access status. Add a pin only when the refreshed state is granted. In either host, deny access or turn location services off and confirm the stop name and notes remain in the in-memory draft.
Show the app preview
Hide the app preview