Guide: launch your app from an NFC tag
Purpose: make a tap on an NFC tag open your app and hand the tag content to shared code. Platforms: Android, iOS. Status: stable.
This guide is for application developers who want a tap on an NFC tag to open their MAUI app and hand the tag content to shared code. It follows the order in which you set the feature up: understand the experience, configure the hosts, write the tags, receive the entries, then diagnose and test.
The guarantees behind it are stated in this guide and in the XML documentation
of INfcLaunchEntryService. The working reference is the
Launch tab of the
reference app.
Its portable flow is in
Services/LaunchFlow.cs.
Every C# snippet below is copied from the reference app or from a compiled snippet source. A test fails when the guide and the compiled code differ.
| # | Section | You will |
|---|---|---|
| 1 | Overview | Learn what users see on each platform |
| 2 | Prerequisites | Check devices, domain and hosting |
| 3 | Quick start | Opt in and receive entries in shared code |
| 4 | iOS configuration | Associate the domain with the app |
| 5 | Android configuration | Declare filters and verify App Links |
| 6 | Writing launch tags | Write tags that work on both platforms |
| 7 | Receiving entries | Handle cold and warm entries and filters |
| 8 | Continue with the tag | Read or write the same tag after the launch |
| 9 | Android-only features | Use data that only Android provides |
| 10 | iOS simulations and limits | Know what iOS cannot do |
| 11 | Diagnostics reference | Look up a reason code or build warning |
| 12 | Troubleshooting | Go from symptom to fix |
| 13 | Security | Treat entries as untrusted input |
| 14 | Testing | Test on devices and simulate Android entries |
| 15 | Migration | Move from the Android-only API |
Overview
Launching from a tag means that the operating system reads a tag while your
app is not scanning, opens (or reactivates) your app and hands it the tag
content. The library captures that content before your first page exists and
delivers it as one portable NfcLaunchEntry through INfcLaunchEntryService.
The code is the same on both platforms.
What the user sees differs:
| Android | iOS | |
|---|---|---|
| Trigger | Screen on and, by default, device unlocked | iPhone in use; no Core NFC session, Wallet or camera active |
| Confirmation | None: the app opens directly | Always: a notification that the user taps; a locked phone asks to unlock first |
| Ambiguity | A chooser when several apps match, unless App Links are verified or the tag has an Android Application Record | None: only the app associated with the domain |
| App not installed | The Android Application Record opens the Play Store | The URL opens in Safari (serve a fallback page) |
| Data | All NDEF messages, UID, technologies, native tag | One NDEF message |
The library never scans in the background: "launch" always means the system read the tag and opened the app. While your app runs its own scan session, tags go to that session, never to the launch path.
Expected parity:
| Behavior | Android | iOS | Uniform result |
|---|---|---|---|
| Opt-in | LaunchEntry (or EnableIntentLaunch) |
LaunchEntry |
Same code |
| Cold and warm entry | Intents | NSUserActivity |
Same NfcLaunchEntry and service |
Launch by https URI first record |
Yes | Yes (universal link) | Same, with the launch tag layout |
| Launch by MIME type | Yes (manifest) | No; content filter after URI launch | Simulated (content filter) |
| Launch by tech list / any tag | Yes | No | Android-only (extensions) |
| Custom URL scheme | Yes | No | Android-only; diagnostic on iOS |
| User confirmation | None (chooser if ambiguous) | Notification tap, unlock | Documented difference |
| Data | All messages, UID, technologies | One message | Portable: first message + URI; rest in Android details |
| Use the tag after entry | Native handle | Re-tap in a new session | Same API (ContinueWithTagAsync) |
| App not installed | AAR → Play Store | Safari → web fallback page | Simulated (store or web fallback) |
| Active session present | Session gets the tag | Background reading disabled | Same rule (no entry during a session) |
| Continuous background scanning | No | No | Non-goal |
Prerequisites
- Android: any device with NFC and Android 8.0 (API 26) or later, the library minimum. API 36 adds a user setting that can block tag intents (see Android-only features).
- iOS: iPhone XS or later. Background tag reading is not available on
older models, and no public API can detect it, so the capability reports
Unknown. The deployment target is the one of the library (iOS 13 or later). - A domain you control, for example
tags.example.org. The tag URL ishttps://<domain>/<path>. iOS opens third-party apps only for universal links, so the scheme must behttps. - HTTPS hosting on that domain, with a publicly trusted certificate, for two
verification files served without redirects or authentication:
/.well-known/apple-app-site-association(iOS);/.well-known/assetlinks.json(Android App Links).
- Signing: an Apple App ID with the Associated Domains capability, and the SHA-256 fingerprint of every Android signing certificate (debug and release).
- Writable NDEF tags (for example NTAG213/215/216) for testing.
Quick start
The minimum setup that launches the app on both platforms has three parts.
1. Opt in once, in shared code. Pass LaunchEntry at the first UseNfc
call. The URI filter describes your tags; capture starts before dependency
injection resolves any service.
// MauiProgram.CreateMauiApp: the same shared code on Android and iOS.
builder.UseNfc(new NfcIntegrationOptions {
LaunchEntry = new NfcLaunchEntryOptions {
UriFilters = [new NfcLaunchUriFilter("https", "tags.example.org", "/nfc")]
}
});
2. Configure the hosts. Associate the domain on iOS (iOS configuration) and declare the intent filters on Android (Android configuration). Without this step the tag opens the browser and nothing reaches the app.
3. Take the pending entry at startup and subscribe to EntryAvailable. The
reference app wraps this in LaunchEntryReceiver. Subscribe first, then take:
// Subscribe first, then take. A cold entry was buffered before the app could subscribe; a warm entry raises
// EntryAvailable. TakePendingAsync consumes an entry exactly once, so the two paths never deliver it twice.
_launch.EntryAvailable += OnEntryAvailable;
await TakeAsync(cancellationToken);
The handler and the take:
// Not async void: nothing observes an event handler, so an escaping exception would terminate the app.
private void OnEntryAvailable(object? sender, EventArgs e) => _ = TakeFromEventAsync();
private async Task TakeFromEventAsync() {
try { await TakeAsync(CancellationToken.None); }
catch (Exception exception) { _faulted(exception); }
}
private async Task TakeAsync(CancellationToken cancellationToken) {
var result = await _launch.TakePendingAsync(cancellationToken);
if (result.Error is { } error) {
// launch.notEnabled without the opt-in, or a captured input error, which is returned only once.
_failed(error);
return;
}
// A successful null means that nothing is pending, for example because another subscriber took the entry.
if (result.Value is { } entry) await _received(entry);
}
Start it once when the app starts (reference app, App.OnStart):
// Once at startup: StartAsync subscribes to EntryAvailable and takes the entry of a cold launch.
if (probe.AutoReceive) await receiver.StartAsync();
Write a tag whose first record is https://tags.example.org/nfc/...
(Writing launch tags) and tap it with the app closed.
iOS configuration
On iOS the system reads the tag, not your app. iOS background tag reading
opens your app only when the first NDEF record of the tag is an https
URL of a domain associated with the app (a universal link). Everything else
fails silently: the user sees a notification that opens the URL in Safari, or
nothing at all.
For every host in NfcLaunchEntryOptions.UriFilters you need:
- an
applinks:<host>entry in the app's Associated Domains entitlement; - an
apple-app-site-association(AASA) file on that host that lists your app and the tag URL paths; - a provisioning profile whose App ID has the Associated Domains capability.
A filter without an https scheme can never launch the app on iOS
(NFC1703 at build time, ios.launch.scheme.unsupported at runtime).
1. Associated Domains entitlement
Add one applinks: entry per https host of UriFilters to the entitlements
file used for signing (CodesignEntitlements, usually
Platforms/iOS/Entitlements.plist):
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:tags.example.org</string>
<!-- A wildcard covers every subdomain, but not example.org itself. -->
<string>applinks:*.example.org</string>
</array>
- The host must match the tag URL host exactly;
applinks:example.orgdoes not covertags.example.org. - During development you can append
?mode=developer(applinks:tags.example.org?mode=developer). The device then fetches the AASA file directly from your server instead of Apple's CDN, so changes apply immediately. It works only with Developer Mode on and Settings > Developer > Associated Domains Development enabled. Remove it for TestFlight and App Store builds. - Enable Associated Domains for the App ID in the Apple Developer portal (Xcode automatic signing does this for you) and regenerate the provisioning profile. A signed entitlement that the profile does not allow makes installation fail.
Instead of editing the plist, you can let the build add the entries. Declare
the launch URIs once in the app project, keeping them aligned with UriFilters:
<ItemGroup>
<NfcLaunchUri Include="https://tags.example.org/nfc" />
</ItemGroup>
<PropertyGroup>
<!-- Optional: add the missing applinks: entries instead of only warning. -->
<NfcGenerateLaunchConfiguration>true</NfcGenerateLaunchConfiguration>
</PropertyGroup>
These MSBuild items come with the NuGet package (build/buildTransitive) and
run only in application projects (OutputType=Exe, or AndroidApplication=true
on Android):
| Property | Default | Effect |
|---|---|---|
NfcGenerateLaunchConfiguration |
false |
true generates the configuration; false validates it. |
NfcValidateLaunchConfiguration |
true |
false turns the targets off completely. |
NfcLaunchEntryActivity |
(empty) | Java name of the Android entry activity. When it is empty, the single MAIN/LAUNCHER activity is used. |
Without generation the build validates the entitlement and
reports warning NFC1702 for every https host without a matching
applinks: entry (wildcards are honored). The result is embedded in the app
assembly, and at runtime the capability snapshot reports the
ios.launch.associatedDomains.missing diagnostic on
NfcFeature.LaunchEntry (kind ConfigurationRequired). The provider also
reports it when a runtime UriFilters host is not covered by the entitlement
validated at build time. iOS cannot read the signed entitlements reliably at
runtime, so an app built without the package targets reports nothing.
// nfc is the resolved INfcService.
var missing = nfc.Capabilities.Diagnostics.Any(d =>
d.Feature == NfcFeature.LaunchEntry && d.Code == "ios.launch.associatedDomains.missing");
2. The apple-app-site-association file
Serve the file on every host listed in applinks:. Complete example for the
team ID ABCDE12345, the bundle ID com.example.app and tags whose URLs start
with https://tags.example.org/nfc/:
{
"applinks": {
"details": [
{
"appIDs": ["ABCDE12345.com.example.app"],
"components": [
{ "/": "/nfc/*", "comment": "NFC launch tags" }
]
}
]
}
}
appIDsis<Team ID>.<bundle ID>. Add one entry per app (for example a separate debug bundle ID) that should open the tags.componentsmust match the path of the URL written on the tag. Paths not listed open in Safari. Add"?"or"#"keys only if you need to match query or fragment.
Hosting rules (Apple rejects the file otherwise, silently):
- URL:
https://<host>/.well-known/apple-app-site-association(no file extension). Serving it also at/apple-app-site-associationis harmless. - HTTPS with a valid, publicly trusted certificate; no redirects; HTTP 200.
Content-Type: application/json; the file must be valid JSON, uncompressed size at most 128 KB.- No authentication, IP filtering or bot protection in front of it: Apple's CDN must be able to fetch it.
- Without
?mode=developer, devices read the file from Apple's CDN, which refreshes it periodically, not instantly. Check what the CDN serves withcurl -i https://app-site-association.cdn-apple.com/a/v1/<host>.
The repository's test site (TestApps/Nementis.Maui.NFC.TestDomainSite) shows
a working static-hosting configuration, including the rewrite and content type.
3. Verify the association
Check the signed entitlements of the built app (on the Mac):
codesign -d --entitlements - --xml "path/to/YourApp.app" | plutil -p -The output must contain
com.apple.developer.associated-domainswith yourapplinks:entries.Check the file is served correctly:
curl -i https://<host>/.well-known/apple-app-site-associationmust return200withapplication/jsonand no redirect.Install the app, then open the tag URL from the Notes app or Messages (not by typing it in Safari's address bar). A long press must offer Open in "YourApp". If it offers only Safari, the association is not verified: recheck the three items above and, during development, Associated Domains Development and
?mode=developer.Write a tag whose first NDEF record is the
httpsURL and tap it with the iPhone unlocked and no app scanning for NFC. iOS shows a notification; tapping it opens the app and delivers the launch entry.
4. The Core NFC reader entitlement is not needed for launch entries
Background tag reading does not require the Core NFC reader entitlement
(com.apple.developer.nfc.readersession.formats), the NFC Tag Reading
capability or IosNfcIntegrationOptions.ReaderSessionFormats. They are needed
only when the app opens its own reader sessions (scans, reads or writes tags
while running, or uses ContinueWithTagAsync, which asks the user to tap again
in a reader session).
An app that only receives launch entries can therefore register the library like this, with only the Associated Domains entitlement:
builder.UseNfc(new IosNfcIntegrationOptions {
LaunchEntry = new NfcLaunchEntryOptions {
UriFilters = [new("https", "tags.example.org", "/nfc")]
}
});
With LaunchEntry set and no ReaderSessionFormats declared, the capability
snapshot does not report the provider-wide
ios.configuration.readerSessionFormats.declarationAndEntitlement diagnostic,
and the LaunchEntry row is unaffected. The reader features (NdefRead,
Discovery, …) still report that reason code, and starting a reader session
still fails with it, so an app that does scan must still declare TAG and sign
the entitlement as described in configure the Android manifest and iOS entitlements.
Device check: the ReferenceApp was signed
with com.apple.developer.associated-domains only (codesign showed no
com.apple.developer.nfc.readersession.formats) and registered without
ReaderSessionFormats. On an iPhone 12 (iPhone13,2) with iOS 27.2.1, tapping a
tag with https://mauitest.nementis.eu/nfc/test opened the app from the
notification, and the Launch tab recorded CAPTURED Cold; a second tap with
the app in the background recorded CAPTURED Warm.
Android configuration
Android routes a tag by the intent filters of your activities. Two filters per launch URL give the best experience:
NDEF_DISCOVEREDfor the URL: the NFC service delivers the tag to your app;- an
ACTION_VIEWApp Link withandroid:autoVerify="true": once the domain is verified, Android opens your app without a chooser. On Android 16 (API 36) the NFC service may deliver a URL tag asACTION_VIEWwith the tag attached; the library accepts it asAndroidViewWithTag.
1. Intent filters: generated or written by hand
First, the NFC permission. The MAUI template's
Platforms/Android/AndroidManifest.xml does not declare it, and the build does
not add it. Without it the capability reports ConfigurationMissing
(android.permission.nfc.missing). Launch intents still arrive, but
ContinueWithTagAsync and scan sessions fail. Add it inside <manifest>:
<uses-permission android:name="android.permission.NFC" />
<!-- Optional hardware: the app still installs on phones without NFC. -->
<uses-feature android:name="android.hardware.nfc" android:required="false" />
Generated (recommended). Declare the same NfcLaunchUri items as for iOS
and turn generation on. The build adds both filters to the MAIN/LAUNCHER
activity (or to NfcLaunchEntryActivity) through a manifest overlay:
<ItemGroup>
<NfcLaunchUri Include="https://tags.example.org/nfc" />
<!-- Optional: Android can also launch by MIME type. -->
<NfcLaunchMimeType Include="application/vnd.example.ticket" />
</ItemGroup>
<PropertyGroup>
<NfcGenerateLaunchConfiguration>true</NfcGenerateLaunchConfiguration>
</PropertyGroup>
By hand. Without generation the build validates the manifest and reports
NFC1701 for each missing filter. The equivalent declaration, inside
<application> of Platforms/Android/AndroidManifest.xml (or as
[IntentFilter] attributes on MainActivity, as the reference app does):
<activity android:name="com.example.app.MainActivity" android:exported="true" android:launchMode="singleTop">
<!-- NFC: tags whose first record is https://tags.example.org/nfc... -->
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" android:host="tags.example.org" android:pathPrefix="/nfc" />
</intent-filter>
<!-- App Link: opens the app without a chooser once the domain is verified. -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="tags.example.org" android:pathPrefix="/nfc" />
</intent-filter>
</activity>
Use LaunchMode.SingleTop so a warm tap reaches the running activity through
OnNewIntent instead of creating a second one. At runtime the provider asks
PackageManager whether the app resolves NDEF_DISCOVERED for each
UriFilters and MimeTypes entry and reports
android.launch.manifest.filterMissing otherwise.
2. The assetlinks.json file
Serve https://<host>/.well-known/assetlinks.json with
Content-Type: application/json, HTTP 200 and no redirect. List every
signing certificate that installs the app:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example.app",
"sha256_cert_fingerprints": [
"14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"
]
}
}
]
Get the fingerprint (SHA256: line) of the keystore that signs the APK. For the
.NET Android debug keystore on Windows:
keytool -list -v -alias androiddebugkey -storepass android -keypass android `
-keystore "$env:LOCALAPPDATA\Xamarin\Mono for Android\debug.keystore"
For a release keystore use its path and alias. For Play App Signing, copy the App signing key certificate SHA-256 from the Play Console (Setup > App integrity): the store re-signs the app, so your upload key fingerprint alone does not verify.
3. Check verification
Install the app, then on API 31 or later:
adb shell pm verify-app-links --re-verify com.example.app
adb shell pm get-app-links com.example.app
tags.example.org: verified means App Links work. none or 1024 means
verification failed: check the fingerprint, the package name, the content type
and that the file is reachable without redirect. On API 26–30 use
adb shell pm get-app-link com.example.app, which must print always.
A control without a tag:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d https://tags.example.org/nfc/test
must open the app directly. This plain deep link is not a launch entry:
the library ignores it.
Writing launch tags
Record order
Use NfcLaunchTag.CreateMessage, from Android or iOS. It builds:
- the
httpsURI record first: iOS routes only on the first URI record, and Android routesNDEF_DISCOVEREDand App Links on it; - your optional payload records (for example a MIME record);
- the optional Android Application Record (AAR) last: Android honors it anywhere, iOS ignores it.
// Record order: the https URI first (iOS and Android route on it), then optional payload records,
// then the optional Android Application Record (AAR) last. A non-https link throws ArgumentException.
NfcLaunchTag.CreateMessage(universalLink, payload: null, androidPackage);
The AAR trade-off
| With AAR | Without AAR | |
|---|---|---|
| Android, app installed | Opens your package; other apps' filters are ignored | Opens your app directly if App Links are verified; otherwise a chooser may appear |
| Android, app missing | Opens the Play Store page of the package | Another handler or the browser opens the URL |
| iOS | No effect | No effect |
Add the AAR when the tag must always reach your Android app. Omit it when another app (or the browser) should also be able to handle the URL, and rely on verified App Links instead. On iOS the missing-app case is handled by a web page on the same URL (iOS simulations and limits).
Capacity, writing and locking
SerializedLength is the exact message size. Compare it with the tag capacity
before writing; an NTAG213 holds 144 bytes, so keep URLs short. Locking with
MakeReadOnlyAsync is optional and irreversible; the portable view exists
only when the tag and the platform support it:
var ndef = tag.GetProtocol<INfcNdefTag>() ?? throw new NotSupportedException("The tag does not expose NDEF.");
var status = await ndef.QueryStatusAsync(cancellationToken);
if (!status.IsSuccess) return status;
// Check the capacity first: the URI, the payload and the AAR must fit in one NDEF message.
if (status.Value.CapacityBytes is { } capacity && launch.SerializedLength > capacity) {
return NfcResult.Failure(NfcOperationContext.Create(status.Context.SessionId, status.Context.TagId),
new NfcError(NfcErrorCode.CapacityExceeded, CapacityReason));
}
var written = await ndef.WriteAsync(launch.Message, new NfcNdefWriteOptions(VerifyAfterWrite: verify), cancellationToken);
if (!written.IsSuccess || !makeReadOnly) return written;
// Optional and irreversible: lock the tag so nobody can rewrite it. The view is null when the tag or
// the platform cannot make it read-only.
if (tag.GetProtocol<INfcNdefReadOnlyTag>() is not { } readOnly) {
return NfcResult.Failure(NfcOperationContext.Create(written.Context.SessionId, written.Context.TagId),
new NfcError(NfcErrorCode.Unsupported, ReadOnlyUnsupportedReason), written.Effects);
}
return await readOnly.MakeReadOnlyAsync(cancellationToken);
In the reference app: Workbench, select NDEF / Write launch tag, enter the link and optionally the Android package, then tap a tag.
Receiving entries
Cold and warm entries
Activation |
Meaning | How it arrives |
|---|---|---|
Cold |
The tap started the process | Buffered before your first page; take it at startup |
Warm |
The process was running, in the background or foreground | EntryAvailable is raised; take it then |
Both arrive through the same TakePendingAsync. EntryAvailable carries no
data and is not raised for entries buffered before you subscribe, so always
subscribe and take once at startup (Quick start).
One pending entry
The library keeps one latest pending entry per owner (Android activity, iOS
application or scene). A newer tap replaces an unconsumed older one, and
destroying the owner discards it. TakePendingAsync:
- returns the entry once, then a successful
null; - leaves the entry pending when cancelled;
- returns a captured input error (for example
android.intent.tag.missing) once, as a failure; - fails with
Configuration(launch.notEnabled) without the opt-in.
On Android the same buffer feeds AndroidNfcIntentDelivery.DeliverPendingAsync:
whichever surface takes the entry first consumes it. With several windows or
activities alive, every subscriber is notified and the first take wins, so take
entries from the foreground window only.
Provenance and trust
| Member | Android | iOS |
|---|---|---|
Id |
New per delivery | New per delivery |
Source |
AndroidNdefDiscovered, AndroidTechDiscovered, AndroidTagDiscovered, AndroidViewWithTag |
IosBackgroundTagReading |
Activation |
Cold or Warm |
Cold or Warm |
ReceivedAt |
Capture time | Capture time |
Ndef |
First message, provenance Cached; NoData if none |
The delivered message, provenance Cached |
PrimaryUri |
First URI record, or null |
The universal link |
Snapshot |
UID and technologies | Always null |
CanContinueWithTag |
true while the native tag is retained |
Always false |
There is no "verified" or "trusted" member: the entry proves that the system read a tag, not that the tag is genuine (Security). Validate the content before acting on it:
// The entry is untrusted input: anyone can write this URL to a tag. Check it again instead of relying on the
// filters, use it only to choose a screen, and validate every sensitive action on the server.
if (!Uri.TryCreate(entry.PrimaryUri, UriKind.Absolute, out var uri)
|| uri.Scheme != Uri.UriSchemeHttps
|| !string.Equals(uri.Host, LaunchSetup.Host, StringComparison.OrdinalIgnoreCase)
|| !uri.AbsolutePath.StartsWith(LaunchSetup.PathPrefix + "/", StringComparison.Ordinal)) {
return null;
}
return uri.AbsolutePath[LaunchSetup.PathPrefix.Length..];
Filters and rejection
NfcLaunchEntryOptions decides which delivered entries reach your code:
UriFilters: scheme and host case-insensitive, path prefix on segment boundaries (/nfcmatches/nfc/a, not/nfcx);MimeTypes: matched against every record of the message;AcceptUnfiltered: accept entries without NDEF data (AndroidTECH_DISCOVERED/TAG_DISCOVERED) when filters are set.
No filters means "accept everything". The reference app's filters:
new() {
// Tags whose first record is https://mauitest.nementis.eu/nfc/... launch the app on both platforms.
UriFilters = [new NfcLaunchUriFilter("https", Host, PathPrefix)],
// Matched against every record. Android can also launch by MIME type; iOS only filters after a URI launch.
MimeTypes = ["text/plain"],
// Android TECH_DISCOVERED entries carry no NDEF data; the workbench demo accepts them.
AcceptUnfiltered = true
};
A rejected entry is not buffered and never reaches TakePendingAsync. It is
reported once to registered INfcOperationObserver instances with reason
launch.filter.rejected. The filters are an addition to the OS routing, not an
authorization boundary, and they never change what Android routes: the manifest
does that. Invalid filters throw ArgumentException at registration.
Active sessions
While your app runs a library scan session, tags go to that session and never
become entries. On iOS the platform disables background reading during
a session, and the capability reports ios.launch.unavailableDuringSession.
On Android an intent received during a suspended session is handled by
foreground dispatch and is not duplicated as an entry.
Inspect the capability
// Availability: Ready on Android, Unknown on iOS (device dependent), ConfigurationMissing without the opt-in.
log($"LaunchEntry: {launch.Capability.Availability} ({launch.Capability.ReasonCode})");
foreach (var diagnostic in nfc.Capabilities.Diagnostics.Where(d => d.Feature == NfcFeature.LaunchEntry)) {
// HelpLink points to the row of the code in the diagnostics reference of this guide.
log($"{diagnostic.Kind} {diagnostic.Code}: {diagnostic.HelpLink}");
}
Continue with the tag
ContinueWithTagAsync gives you a live tag after an entry, with one API:
- Android: if
CanContinueWithTagis true, the retained tag is published into a new session without another tap; its live message is still checked. If the tag has left the field, the session waits for a matching tap. - iOS: background reading retains no tag. The call opens the system sheet
with your prompt and the user taps the same tag again. A different tag is
rejected, the prompt changes to
MismatchMessageand scanning continues (ios.launch.continuation.requiresRetap).
var options = new NfcLaunchContinuationOptions {
// SameMessage (the default) compares every record; SamePrimaryUri compares only the launch URL.
Match = NfcLaunchTagMatch.SamePrimaryUri,
// Shown on the iOS sheet; on Android the host renders it (no system sheet).
Prompt = new NfcScanPrompt(Scanning: "Hold the same tag near the phone again."),
MismatchMessage = "This is a different tag. Use the tag that opened the app.",
Timeout = TimeSpan.FromSeconds(30)
};
var continued = await launch.ContinueWithTagAsync(entry, options, cancellationToken);
if (continued.Error is { } error) {
// For example Timeout (launch.continuation.timeout), Cancelled, or Busy while another session is active.
return NfcResult<NfcNdefData>.Failure(continued.Context, error, continued.Effects);
}
// Disposing the continuation stops its session and invalidates the tag.
await using var continuation = continued.Value;
var ndef = continuation.Tag.GetProtocol<INfcNdefTag>()
?? throw new NotSupportedException("The tag does not expose NDEF.");
return await ndef.ReadAsync(cancellationToken);
Design the UX for the re-tap on iOS: explain why a second tap is needed
before calling, keep the default 30-second timeout or longer, and offer a retry
after launch.continuation.timeout. Only one session can be active; another one
makes the call fail with Busy. The continuation needs the Core NFC reader
entitlement on iOS (configure the Android manifest and iOS entitlements).
Android-only features
Not portable. Everything in this section exists only on Android. Shared code must not depend on it; check
entry.Snapshot is not nullorGetAndroidDetails() is not nullinstead of the platform.
AndroidNfcLaunchDetails exposes copies of the intent data: the action,
all EXTRA_NDEF_MESSAGES messages, EXTRA_ID (UID), the technologies, the
matched data URI and MIME type, and the receiving component.
// Portable check: only Android entries carry a snapshot (UID and technologies).
if (entry.Snapshot is not null) log($"Technologies: {entry.Snapshot.Technologies.Length}");
// Android-only data; GetAndroidDetails returns null for iOS entries.
if (entry.GetAndroidDetails() is { } details) {
log($"{details.Action}: {details.NdefMessages.Length} messages, MIME {details.MimeType ?? "none"}");
log($"UID present: {details.TagId is not null}; technologies: {string.Join(", ", details.Technologies)}");
}
MIME, technology and custom-scheme routing. Android can launch the app from
a MIME type (NDEF_DISCOVERED with DataMimeType), a technology list
(TECH_DISCOVERED with an nfc_technologies.xml resource), any tag
(TAG_DISCOVERED) or a custom URL scheme (myapp://...). Declare them in the
manifest as usual; the portable filters only decide which entries are
delivered. Entries without NDEF data need AcceptUnfiltered = true when you set
filters. None of these launch an iOS app.
Native tag and UID. The UID is in Snapshot.Identifier and
AndroidNfcLaunchDetails.TagId. The native tag stays inside the library: use it
through ContinueWithTagAsync, which can also require the same UID on Android:
// Android only: also require the same tag UID. The portable options have no UID, because iOS entries carry none.
new AndroidNfcLaunchContinuationOptions { Match = NfcLaunchTagMatch.SameMessage, SameIdentifier = true };
Your own activity callbacks. The native Intent is never exposed. If you
also read NFC intents yourself, skip those the library already captured:
// In your own activity callbacks: skip an NFC intent that the library already captured.
intent.GetBooleanExtra(AndroidNfcLaunchExtensions.ConsumedIntentExtra, false);
API 36 tag-intent preference. Android 16 lets the user forbid tag intents
for an app. The library then reports android.launch.tagIntent.restricted
(availability Restricted). Send the user to the setting:
// API 36: the user can forbid tag intents for the app. Send them to the system setting.
if (launch.Capability.ReasonCode == "android.launch.tagIntent.restricted") {
return await management.OpenSettingsAsync(AndroidNfcSettingsPage.TagIntentPreference);
}
iOS simulations and limits
Content routing. Android can launch by MIME type; iOS cannot. The
closest honest equivalent: launch by the https URI, then evaluate
MimeTypes against all records of the message. With the
launch layout both platforms accept the same entries. A
MIME-only tag (no https URI first) cannot launch an iOS app.
Web fallback. With an AAR, Android opens the Play Store when the app
is missing. On iOS the universal link opens Safari, so serve a page at the
launch URL that offers both stores. The template is
Web/nfc/index.html:
its apple-itunes-app meta tag shows the Smart App Banner in Safari, and its
links point to the App Store and to
play.google.com/store/apps/details?id=<package>. Replace APP_STORE_ID and
ANDROID_PACKAGE. App Clips are an optional iOS alternative if the URL is
registered as an App Clip experience; the library does not depend on them.
Limits that cannot be simulated:
| Limit | Reason code |
|---|---|
| The user must tap a notification, and unlock first | ios.launch.userConfirmationRequired |
| Only the first URI record routes the launch | ios.launch.firstUriRecordOnly |
| No UID, technology or tag handle | ios.launch.noTagIdentity |
No TECH_DISCOVERED/TAG_DISCOVERED routing |
ios.launch.routing.techTag.unsupportedByPlatform |
| No custom URL schemes | ios.launch.scheme.unsupported |
| Device support cannot be detected | ios.launch.deviceDependent |
| Disabled while a reader session is active | ios.launch.unavailableDuringSession |
| Using the tag needs a second tap | ios.launch.continuation.requiresRetap |
Diagnostics reference
Launch diagnostics are reported on NfcFeature.LaunchEntry in
INfcService.Capabilities.Diagnostics and by INfcLaunchEntryService.Capability.
Each NfcCapabilityDiagnostic.HelpLink (and NfcLaunchGuide.GetHelpLink(code)
for result reason codes) points to the row below; the build warnings carry the
same link as their HelpLink.
| Code | Kind | Platform | Meaning | Corrective action |
|---|---|---|---|---|
launch.notEnabled |
ConfigurationRequired | Both | The host did not opt in. Nothing is captured, and TakePendingAsync fails with Configuration. |
Set NfcIntegrationOptions.LaunchEntry at the first UseNfc/AddNfc call. |
launch.notImplemented |
Capability reason | Other targets (net10.0) |
No launch-entry implementation; TakePendingAsync fails with Unsupported. |
Run on Android or iOS. |
launch.entry.notBackgroundScanning |
Limitation | Both | Entries come only from tags the system reads; the library never scans in the background. | None. Start a scan session to read tags while the app runs. |
launch.entry.untrusted |
Limitation | Both | Entry content comes from an arbitrary tag and can be forged or cloned. | Validate the content; validate sensitive actions on a server (Security). |
launch.scheme.insecure |
Limitation | Both | A UriFilters entry uses http, which is unencrypted and spoofable. |
Use https. |
launch.filter.rejected |
Limitation | Both | Filters are set: non-matching entries are discarded and reported to INfcOperationObserver with this code. |
Align the tag content with UriFilters/MimeTypes, or set AcceptUnfiltered for entries without NDEF data. |
ios.launch.userConfirmationRequired |
Limitation | iOS | iOS shows a notification; the app opens only when the user taps it (after unlocking). | Explain it in your UX; there is no silent launch. |
ios.launch.firstUriRecordOnly |
Limitation | iOS | iOS routes only by the first URI record of the message. | Write the https URI first (Writing launch tags). |
ios.launch.noTagIdentity |
Limitation | iOS | Entries carry no UID, technology or tag handle; Snapshot is null. |
Do not depend on the UID in shared code; use ContinueWithTagAsync for a live tag. |
ios.launch.unavailableDuringSession |
Limitation | iOS | Reported while a library reader session is active: iOS suspends background reading. | Expected. Stop sessions you no longer need. |
ios.launch.associatedDomains.missing |
ConfigurationRequired | iOS | The build found a UriFilters/NfcLaunchUri host without an applinks: entry. |
Add applinks:<host> or set NfcGenerateLaunchConfiguration, then rebuild (iOS configuration). |
ios.launch.scheme.unsupported |
ConfigurationRequired | iOS | A URI filter does not use https; iOS background reading cannot launch the app with it. |
Use an https universal link for iOS; keep custom schemes Android-only. |
ios.launch.deviceDependent |
Limitation | iOS | Background tag reading needs an iPhone XS or later and cannot be detected; availability is Unknown. |
Test on a supported device; do not promise the feature on older models. |
ios.launch.continuation.requiresRetap |
Limitation | iOS | ContinueWithTagAsync asks the user to tap the tag again. |
Explain the second tap in the prompt (Continue with the tag). |
ios.launch.routing.techTag.unsupportedByPlatform |
Limitation | iOS | iOS cannot launch by technology or for any tag (TECH_DISCOVERED/TAG_DISCOVERED). |
Use the launch layout; keep technology routing Android-only. |
android.launch.manifest.filterMissing |
ConfigurationRequired | Android | PackageManager does not resolve NDEF_DISCOVERED to the app for a UriFilters/MimeTypes entry. |
Add the intent filters or enable generation (Android configuration). |
android.launch.tagIntent.restricted |
Limitation | Android (API 36) | The user disallowed tag intents for the app; availability is Restricted. |
Open AndroidNfcSettingsPage.TagIntentPreference (Android-only features). |
launch.continuation.timeout |
Result reason | Both | No matching tag before NfcLaunchContinuationOptions.Timeout. |
Offer a retry, or use a longer timeout. |
launch.continuation.message.missing |
Result reason | Both | SameMessage was requested for an entry without NDEF data. |
Use Any, or continue only entries with a message. |
launch.continuation.primaryUri.missing |
Result reason | Both | SamePrimaryUri was requested for an entry without PrimaryUri. |
Use SameMessage or Any. |
launch.continuation.identifier.missing |
Result reason | Android | SameIdentifier was requested for an entry without a UID. |
Drop SameIdentifier for that entry. |
launch.continuation.cleanup.failed |
Result reason | Both | The continuation session could not be released cleanly (reported as CleanupError). |
Treat the continuation as ended; retry after the session has stopped. |
NFC1700 |
Build error | Both | An NfcLaunchUri/NfcLaunchMimeType item is invalid, or generation found no unique entry activity. |
Fix the item (absolute URI with scheme and host; type/subtype), or set NfcLaunchEntryActivity. |
NFC1701 |
Build warning | Android | A launch URI or MIME type has no NDEF_DISCOVERED filter, an https URI has no App Link filter, or generation needs manifestmerger.jar. |
Add the filters or set NfcGenerateLaunchConfiguration (Android configuration). |
NFC1702 |
Build warning | iOS | The Associated Domains entitlement has no applinks: entry for an https launch host. |
Add the entry or set NfcGenerateLaunchConfiguration (iOS configuration). |
NFC1703 |
Build warning | iOS | A launch URI does not use https, so it cannot launch the iOS app. |
Use an https universal link. |
Captured Android input errors are returned once by TakePendingAsync:
android.intent.tag.missing (the intent has no valid EXTRA_TAG, for example
one sent with adb) and android.intent.route.invalid (the intent was not
addressed to the receiving activity).
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| iOS: the tag opens the URL in Safari | Domain not associated: missing applinks: entry, AASA not served (redirect, wrong content type, path not in components), profile without Associated Domains, or the CDN has an old file |
Follow Verify the association; check NFC1702 and ios.launch.associatedDomains.missing; use ?mode=developer while developing |
| Android: the tag opens the browser | No NDEF_DISCOVERED filter for the URL, or on API 36 an unverified App Link |
Check NFC1701/android.launch.manifest.filterMissing; verify App Links (Check verification) |
| iOS: no notification appears | First record is not an https URI, iPhone older than XS, phone never unlocked since boot, a Core NFC session, Wallet or camera is active, or airplane mode |
Use the launch layout; test on a supported, unlocked iPhone with no app scanning |
| Android shows a chooser | Several apps match the URL and App Links are not verified | Verify assetlinks.json, or add the AAR to the tag |
| Android opens the Play Store although the app is installed | The AAR names another package (for example the release ID with a debug build), or the tag intent preference is off on API 36 | Write the installed ApplicationId; check android.launch.tagIntent.restricted |
| No entry after a warm start | EntryAvailable not subscribed, the entry was taken elsewhere, or (Android) the activity is not SingleTop/exported so the intent did not reach it |
Subscribe at startup (Quick start); use LaunchMode.SingleTop; check that UseNfc received LaunchEntry |
| No entry at all | No opt-in (launch.notEnabled), or a library scan session was active |
Set LaunchEntry at the first registration; stop sessions before testing |
TakePendingAsync returns null |
The entry was already consumed: by another subscriber, another window, or AndroidNfcIntentDelivery.DeliverPendingAsync |
Take from one place only; one tap produces one entry |
| The entry is rejected by a filter | Tag content does not match UriFilters/MimeTypes (host, path segment, MIME), or an Android entry without NDEF data with AcceptUnfiltered = false |
Observe launch.filter.rejected with an INfcOperationObserver; align filters and tags |
TakePendingAsync fails with android.intent.tag.missing |
The intent had no tag, for example an adb simulation |
Expected for adb; use a real tag for a real entry |
Android: LaunchEntry reports ConfigurationMissing (android.permission.nfc.missing) |
The manifest does not declare android.permission.NFC (the MAUI template does not) |
Add the permission (Android configuration) |
Security
- Entries are untrusted input. A tag can be cloned, forged or rewritten; on Android another app can send a crafted intent to an exported activity; a universal link proves who owns the domain, not that the tag is genuine. The library offers no "verified" flag.
- Validate the content like any external input and use it only to choose what to show (Provenance and trust). For sensitive actions (payments, check-in, unlocking), validate the request on your server or require signed payloads (for example the NFC Forum Signature RTD).
- Never put secrets in a tag: no credentials, tokens, keys or personal data. Anyone with a phone can read it. Use an opaque identifier that your server resolves.
- A UID is not an authentication factor: it can be emulated.
- Do not log the payload, URI or UID.
NfcLaunchEntry.ToString()redacts them, and the library's launch path writes no log. - Lock production tags with
MakeReadOnlyAsyncwhen nobody should rewrite them (Writing launch tags).
Testing
Launch entries need real devices: the iOS simulator cannot read tags, and only a real tap gives Android a tag object.
Device cases. Test each on Android (oldest and newest API level you support) and on an iPhone XS or later:
| Case | Expected |
|---|---|
| Cold launch (app closed) | One entry, Activation Cold |
| Warm launch from background | EntryAvailable, entry Warm |
| Foreground entry without a session | Entry Warm |
| Entry during an active session | No entry: the session gets the tag |
| Locked device | iOS asks to unlock; Android needs unlock by default |
| App not installed | Android: AAR → Play Store; iOS: Safari with the fallback page |
| Android App Links verified / not verified | Direct launch / chooser or browser |
ContinueWithTagAsync, tag in the field / removed |
Android reuses the tag / waits for a tap; iOS always asks for a tap |
| iOS: same URL opened from Notes or Messages | No entry: it is an ordinary deep link |
The reference app's Launch tab logs every step without printing URIs or UIDs; the results recorded for the library are in device validation, one per scenario and device.
Simulating Android routing with adb. adb shell am start sends the same
intent the NFC service would, so it checks the manifest filters and the capture
path without a tag:
# NDEF_DISCOVERED for a launch URL, resolved inside com.example.app.
adb shell am start -W -a android.nfc.action.NDEF_DISCOVERED -c android.intent.category.DEFAULT \
-d "https://tags.example.org/nfc/test" com.example.app
If the app opens, the filter matches. adb cannot attach the native tag
(EXTRA_TAG), so by design the library does not create an entry:
TakePendingAsync returns the captured error android.intent.tag.missing once.
That proves that routing and the opt-in work. A VIEW intent sent with adb
has no tag either and is ignored as an ordinary deep link. For a complete entry
use a real tag; the library's automated tests use a mocked tag
(DispatchInstrumentation).
Automated tests. Keep your entry handling in plain classes behind
INfcLaunchEntryService, as LaunchEntryReceiver does, and test it with a fake
service: LaunchFlowTests in the reference app tests shows cold, warm,
failure, routing, writing and continuation cases.
Migration
The Android-only intent-entry API keeps working. Move to the portable service to share the code with iOS.
Before, Android only:
// Before: Android-only opt-in. The entry was drained into an active foreground-dispatch session.
new AndroidNfcIntegrationOptions { EnableIntentLaunch = true };
// Still supported: publishes the pending entry's tag to the session's TagDiscovered handlers.
// It shares one buffer with INfcLaunchEntryService: whichever surface takes the entry first consumes it.
var delivered = await delivery.DeliverPendingAsync(session);
After, on both platforms (AndroidNfcIntegrationOptions derives from
NfcIntegrationOptions, so Android-only options can stay):
// After: the portable opt-in, shared with iOS. Android-only options stay available on the same object.
new AndroidNfcIntegrationOptions {
LaunchEntry = new NfcLaunchEntryOptions { UriFilters = [new("https", "tags.example.org", "/nfc")] }
};
Then replace the drain with TakePendingAsync at startup and on
EntryAvailable (Quick start). Use ContinueWithTagAsync when
you need the tag itself.
| Status | |
|---|---|
AndroidNfcIntegrationOptions.EnableIntentLaunch |
Supported. Alone it implies a default LaunchEntry. Setting it to false together with LaunchEntry throws ArgumentException. Prefer LaunchEntry. |
AndroidNfcIntentDelivery.DeliverPendingAsync |
Supported, same signature and semantics. It shares the buffer with INfcLaunchEntryService; use one surface per app. |
NfcFeature.AndroidIntentEntry |
Still reported, with the same availability as NfcFeature.LaunchEntry on Android. |
Manifest filters (MIME, URI, tech list, TAG_DISCOVERED) |
Unchanged; portable filters only narrow delivery. |
| Native intent data | Use GetAndroidDetails(); the native Intent is not exposed. |
Nothing is deprecated: the portable service is the recommended surface, and the Android API remains for Android-only hosts.