Explanation: design choices
Purpose: explain the principles behind the library's API and its limits. Platforms: Android, iOS. Status: stable.
Report what the platform supports, never emulate it
Android and iOS expose different NFC capabilities. The library offers one portable contract for what both do
and keeps platform-only features in AndroidExtensions and IosExtensions. When a feature is missing it
returns a typed result and a capability report; it never fakes success. The
capability matrix is generated from the providers, so documentation cannot
promise more than the code delivers.
Deliberately excluded:
| Not provided | Why |
|---|---|
Automatic session restart (ReconfigureAsync) on iOS |
Core NFC needs a new user action for a new session. |
| NDEF formatting on iOS | Core NFC does not offer it. |
| Tag emulation (HCE), payments, secure elements | Outside a reader/writer library. |
| Continuous background scanning | Neither platform allows it for ordinary apps; only launch from a tag is supported. |
Expected failures are results
NFC fails often and for ordinary reasons: the tag moves, the user cancels, the radio is off. These are typed
NfcResult outcomes with stable reason codes, so apps can branch and localize without catching exceptions or
parsing messages. Exceptions remain for programming errors (invalid arguments, use after disposal) and for
disposal that cannot confirm release.
Effects are separate from success
A write can complete while its verification fails, or succeed while cleanup fails. Folding these into one
boolean would hide facts the app needs. NfcOperationEffects keeps mutation, verification and cleanup
independent, and the library never retries or replays an operation. See cancellation.
Explicit ownership and lifetimes
Sessions, tags and connections are owned, disposable objects with one owner at a time, so concurrent code cannot silently interfere. See ownership and quarantine.
Headless and testable
The library has no UI. The portable contracts are a pure .NET assembly, so app workflows can be unit tested
without devices, and one coordinator dispatches all notifications in order on the MAUI main thread or a
supplied INfcEventDispatcher.
Related
- Overview: Nementis.Maui.NFC overview.
- What each platform supports: capability matrix.