Read NFC tags on iOS

Check real NFC read availability and the missing Core NFC integration. A native tag read remains blocked.
iOS

What you will build

Identify the provider and signing prerequisites still needed before this app can meet its original iPhone tag-reading goal.
Query the active provider instead of returning a fabricated tag
Distinguish usage text and entitlements from an implemented scan session
Keep the native reading goal explicitly open until a real provider and phone checks exist
Status: blocked — a real NFC read on iOS is not implemented by this tutorial. The normal iOS shell registers UnsupportedNfcHost; adding an entitlement does not supply a Core NFC provider.
A fabricated tag would let us demonstrate a result card, but it would hide the part this tutorial promises to teach. Instead, the small app below queries the actual host's read support. It reports unsupported capability without pretending that a label, serial number or NDEF record came from an iPhone.

Create a diagnostic project, not a simulated feature

Complete iOS setup first. These commands declare the capability and generate platform inputs; they do not remove the native provider gap.
cargo install cargo-fission
fission init ios-read-nfc-tags-on-ios
cd ios-read-nfc-tags-on-ios
fission add-target ios --project-dir .
fission add-capability nfc --project-dir .
cargo add serde_yaml

Run the finished example

fission run --target ios --project-dir .

1. Ask the actual provider

Keep the generated src/main.rs and replace the shared files below. The view is side-effect-free; the explicit button queues one request, binds both unit completion actions and decodes the actual typed response. Neither the normal launcher nor the preview installs a memory provider.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/app/state.rs","value":"src-app-state-rs"},{"index":2,"label":"src/app/screen.rs","value":"src-app-screen-rs"},{"index":3,"label":"src/i18n.rs","value":"src-i18n-rs"},{"index":4,"label":"src/lib.rs","value":"src-lib-rs"},{"index":5,"label":"preview/lib.rs","value":"preview-lib-rs"},{"index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
mod screen;
pub mod state;
pub use screen::NfcDiagnosticScreen;
pub use state::NfcDiagnosticState;
{"id":"fission-tabs-1","index":1,"label":"src/app/state.rs","value":"src-app-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct NfcDiagnosticState {
    pub locale: Locale,
    pub pending: bool,
    pub message_key: String,
    pub diagnostic: Option<String>,
}
impl Default for NfcDiagnosticState {
    fn default() -> Self {
        Self {
            locale: Locale::from("en-US"),
            pending: false,
            message_key: "check.ready".into(),
            diagnostic: None,
        }
    }
}
impl GlobalState for NfcDiagnosticState {}

pub fn check_host(state: &mut NfcDiagnosticState, cx: &mut ReducerContext<NfcDiagnosticState>) {
    if state.pending {
        return;
    }
    state.pending = true;
    state.message_key = "check.pending".into();
    state.diagnostic = None;
    let ok = cx.effects.bind(HostChecked, reduce_with!(host_checked));
    let err = cx
        .effects
        .bind(HostCheckFailed, reduce_with!(host_check_failed));
    cx.effects.nfc().availability().on_ok(ok).on_err(err);
}

#[fission_reducer(HostChecked)]
fn host_checked(state: &mut NfcDiagnosticState, cx: &mut ReducerContext<NfcDiagnosticState>) {
    state.pending = false;
    match cx.input.capability_ok(GET_NFC_AVAILABILITY) {
        Some(value) => {
            state.message_key = if value.supported && value.read {
                "check.available"
            } else {
                "check.unavailable"
            }
            .into();
            state.diagnostic = Some(format!("{value:?}"));
        }
        None => state.message_key = "check.invalid".into(),
    }
}

#[fission_reducer(HostCheckFailed)]
fn host_check_failed(state: &mut NfcDiagnosticState, cx: &mut ReducerContext<NfcDiagnosticState>) {
    state.pending = false;
    match cx.input.capability_error(GET_NFC_AVAILABILITY) {
        Some(error) => {
            state.message_key = if error.code == "unsupported" {
                "check.unavailable"
            } else {
                "check.failed"
            }
            .into();
            state.diagnostic = Some(format!("{}: {}", error.code, error.message));
        }
        None => state.message_key = "check.invalid".into(),
    }
}
{"id":"fission-tabs-1","index":2,"label":"src/app/screen.rs","value":"src-app-screen-rs"}
use super::state::{check_host, NfcDiagnosticState};
use fission::prelude::*;

fission_component! {
    pub NfcDiagnosticScreen<NfcDiagnosticState> {}
    view(_screen, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
    } => SafeArea(child: Scroll(child: Container(
        Column(gap: tokens.spacing.m, children: [
            Text(cx.tr("check.heading")).size(tokens.typography.heading2_size),
            Text(cx.tr("check.blocked")).color(tokens.colors.text_secondary),
            Row(gap: tokens.spacing.s, children: [
                Button(child: Text(cx.tr("language.english")), key: "english",
                    on_press: reduce { state.locale = Locale::from("en-US"); }),
                Button(child: Text(cx.tr("language.spanish")), key: "spanish",
                    on_press: reduce { state.locale = Locale::from("es-ES"); }),
            ]),
            Button(child: Text(cx.tr("check.request")), key: "check-host", disabled: state.pending,
                on_press: reduce { check_host(state, cx); })
                .semantics_identifier("host.check"),
            if state.pending {
                Spinner(motion: Some(SpinnerMotion::Default), label: Some(cx.tr("check.pending")))
            },
            Text(cx.tr(&state.message_key)),
            if let Some(details) = &state.diagnostic { Code(text: details.clone()) },
            Text(cx.tr("check.scope")).color(tokens.colors.text_secondary),
        ])
    ).padding_all(tokens.spacing.l)))
}
{"id":"fission-tabs-1","index":3,"label":"src/i18n.rs","value":"src-i18n-rs"}
use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;
use std::collections::HashMap;

pub fn create_env() -> Env {
    let mut env = Env::default();
    env.locale = Locale::from("en-US");
    for (locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid task translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(locale),
            messages,
        });
    }
    env
}

pub fn sync_env(state: &crate::app::NfcDiagnosticState, env: &mut Env) {
    env.locale = state.locale.clone();
}
{"id":"fission-tabs-1","index":4,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod i18n;

use app::{NfcDiagnosticScreen, NfcDiagnosticState};
use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<NfcDiagnosticState, _>::new(NfcDiagnosticScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> {
    MobileApp::<NfcDiagnosticState, _>::new(NfcDiagnosticScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
}

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = MobileApp::<NfcDiagnosticState, _>::new(NfcDiagnosticScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .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::<NfcDiagnosticState, _>::new(NfcDiagnosticScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":5,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod i18n;

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

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<app::NfcDiagnosticState, _>::new(app::NfcDiagnosticScreen)
        .with_env(i18n::create_env())
        .with_sync_env(i18n::sync_env)
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
check.heading: "Check NFC read support"
check.blocked: "The native iOS tutorial goal is blocked. This screen checks a prerequisite; it does not implement the promised feature."
check.request: "Check the active host"
check.ready: "No host check has been requested."
check.pending: "Waiting for the host…"
check.available: "This host reports NFC read support. No tag has been scanned."
check.unavailable: "The active host cannot provide this prerequisite or operation."
check.failed: "The host check failed. Inspect the diagnostic details."
check.invalid: "The host returned no usable typed result."
check.scope: "This is an integration diagnostic, not a completed native workflow."
language.english: "English"
language.spanish: "Español"
{"id":"fission-tabs-1","index":7,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
check.heading: "Comprueba la lectura NFC"
check.blocked: "El objetivo nativo de iOS está bloqueado. Esta pantalla comprueba un requisito; no implementa la función prometida."
check.request: "Comprobar el host activo"
check.ready: "No se ha solicitado ninguna comprobación."
check.pending: "Esperando al host…"
check.available: "Este host indica compatibilidad con lectura NFC. No se ha leído ninguna etiqueta."
check.unavailable: "El host activo no puede proporcionar este requisito u operación."
check.failed: "La comprobación falló. Revisa los detalles de diagnóstico."
check.invalid: "El host no devolvió un resultado tipado utilizable."
check.scope: "Es un diagnóstico de integración, no un flujo nativo completo."
language.english: "Inglés"
language.spanish: "Español"
{"id":"fission-tabs-1"}
Run the host check. Inspect the actual response and the blocked-goal notice together. A successful request transport is not proof that the requested capability exists.
Show the app preview
Hide the app preview

2. Keep the missing integration visible

GET_NFC_AVAILABILITY returns the active provider's support flags. The default iOS provider returns all flags false; its scan operation returns a typed unsupported error. An availability query succeeding therefore does not mean NFC reading is available.
The generated NFC capability configuration includes NFCReaderUsageDescription and the NDEF reader entitlement. Those are necessary platform inputs, not evidence of a running Core NFC scan session. Keep the purpose description accurate and inspect the final signed entitlements when a real provider is added.
Finishing this goal requires the native scan-session integration, normal bound completion actions which decode the real NfcTag, and physical-device verification of cancellation, timeout, unsupported tags and valid NDEF data. No tag should authorize access merely because its readable identifier matches a string.
Retry the check and change language. There must be no fabricated record, credential, saved setting or completed operation. The diagnostic output is developer evidence, not a user-facing success receipt.
Show the app preview
Hide the app preview

3. What still has to be established

On macOS, launch the actual generated iOS host:
fission doctor ios --project-dir .
fission devices --project-dir .
fission run --target ios --project-dir .
fission test --target ios --project-dir .
These commands can check setup and launch. They cannot certify a missing provider. Follow physical iPhone installation when the real native integration is available.
Use compatible physical hardware for a real scan. Confirm the native prompt, hold a known tag near the reader and inspect the bytes returned by the actual provider. A simulator, browser support flag or memory-provider result cannot establish that behaviour. The original native goal remains open until these checks are possible.