public final class NfcReadOptions
- Object
- NfcReadOptions
Configures a single call to Nfc.readTag(NfcReadOptions) or
Nfc.addTagListener(NfcListener). Setters return this for fluent
chaining; every property has a useful default.
Not every option is honoured on every platform – iOS displays the
system NFC sheet whose copy comes from setAlertMessage(String) but
ignores setTechFilter(TagType...) since Core NFC chooses session type
from the entitlement. Unrecognised settings are silently ignored, so
callers can set the union without platform if statements.
Constructors
public NfcReadOptions() |
Methods
Inherited methods
Constructor details
NfcReadOptions
public NfcReadOptions()Method details
getAlertMessage
public String getAlertMessage()The current message shown on iOS Core NFC’s system sheet. Defaults
to
"Hold your iPhone near the NFC tag". Ignored on Android (no
system sheet) and on the fallback base class.setAlertMessage
public NfcReadOptions setAlertMessage(String alertMessage)Sets the message shown on iOS Core NFC’s modal sheet while the
session is active. Translate this string for your locale before
calling
Nfc.readTag(NfcReadOptions). Ignored on Android.getInvalidatedMessage
public String getInvalidatedMessage()Message shown on the iOS sheet after the session is invalidated
because of an error, or
null to leave it unset. Ignored on
Android.setInvalidatedMessage
public NfcReadOptions setInvalidatedMessage(String invalidatedMessage)Sets the message shown on the iOS sheet after the session ends in
failure. Ignored on Android.
getTechFilter
public List<TagType> getTechFilter()The currently configured technology filter. Empty list means “any
technology”, which is the default.
setTechFilter
public NfcReadOptions setTechFilter(TagType... types)Restricts the reader session to the listed technologies. On Android
the foreground-dispatch intent filter is computed from this list.
iOS picks the underlying session type (
NFCNDEFReaderSession for
TagType.NDEF only, otherwise NFCTagReaderSession).isNdefOnly
public boolean isNdefOnly()true when the session is restricted to tags that already carry an
NDEF payload. Shortcut for setting setTechFilter(TagType...) to
[NDEF]. iOS uses this to pick NFCNDEFReaderSession instead of
NFCTagReaderSession.setNdefOnly
public NfcReadOptions setNdefOnly(boolean ndefOnly)Restricts the session to NDEF-formatted tags. This is the fastest /
most permissive iOS Core NFC mode and the only one that does not
require the
NFCReaderSession entitlement on iOS 13.getTimeoutMs
public long getTimeoutMs()Session timeout in milliseconds.
0 means “no timeout” (the
default); the session ends only when the user dismisses it or a tag
is read. On iOS Core NFC the session is hard-capped at 60 seconds
regardless of this value.setTimeoutMs
public NfcReadOptions setTimeoutMs(long timeoutMs)Stops the session automatically after the given duration. Honoured
on Android and on the JavaSE simulator; iOS Core NFC always uses
its own 60-second hard limit.
getFelicaSystemCodes
public List<String> getFelicaSystemCodes()FeliCa system codes to scan for (e.g.
["0003", "8008"]). Honoured
only on iOS where the codes must also appear in the app’s plist
under
com.apple.developer.nfc.readersession.felica.systemcodes.setFelicaSystemCodes
public NfcReadOptions setFelicaSystemCodes(String... codes)Sets the FeliCa system codes the iOS reader session looks for.
Ignored on Android.
getIsoSelectAids
public List<byte[]> getIsoSelectAids()ISO 7816 AIDs the iOS reader session auto-SELECTs on connection.
Each AID must be a 5-16 byte byte array. Honoured only on iOS where
the AIDs must also appear in
com.apple.developer.nfc.readersession.iso7816.select-identifiers.setIsoSelectAids
public NfcReadOptions setIsoSelectAids(byte[]... aids)Sets the ISO 7816 AIDs the iOS reader session auto-SELECTs on
connection. The bytes are defensively copied. Ignored on Android.