nfc_util 2.0.0
nfc_util: ^2.0.0 copied to clipboard
A Flutter plugin providing access to NFC features on Android and iOS.
2.0.0 #
Requirements #
- Minimum Flutter is now 3.44.0. That is the first stable release which stages the
FlutterFrameworkSwift package, whichios/nfc_util/Package.swiftnow depends on as the Flutter tool requires. - Minimum iOS deployment target is 15.6, declared by both the podspec and
Package.swift.
Breaking #
- Removed the unused
flutter createboilerplate:NfcUtilPlatform,MethodChannelNfcUtiland theplugin_platform_interfacedependency. These were never part of the NFC API. Ndef.read()now returnsFuture<NdefMessage?>. A tag with no NDEF message previously crashed with aTypeErrorinstead of reporting "nothing written yet".MifareClassic.transceivetakesUint8List datainstead ofint data.- The Objective-C shim (
NfcUtilPlugin.h/.m) is gone and the Swift class is now namedNfcUtilPlugininstead ofSwiftNfcUtilPlugin. Swift Package Manager does not support mixed-language targets, and the shim only existed to expose the Swift class to Objective-C. Nothing referenced these types from application code.
Fixed #
-
iOS builds work again under Swift Package Manager.
Package.swiftdeclared its sources atClasses/, which does not exist inside the package root, so the target was empty andxcodebuildrefused to resolve it. Since Flutter 3.44 enables SPM by default, this failed every iOS build. The native sources now live atios/nfc_util/Sources/nfc_util/, shared by both the podspec andPackage.swift. -
Android: implemented every tag I/O method.
Ndef#read/write/writeLock,NfcA/NfcB/NfcF/NfcV/IsoDep#transceive, all nineMifareClassiccommands, the threeMifareUltralightcommands andNdefFormatable#format/formatReadOnlypreviously threwMissingPluginException. Tag I/O runs on a dedicated thread and reuses the open connection, so aMifareClassicsector authentication still holds for the followingreadBlock. -
iOS: tag I/O inside
onDiscoveredworks again. 1.0.3 invalidated the session as soon as a tag was serialized, soNdef.read()/write(),Iso7816.sendCommand()and friends failed with "Tag is not found". WithinvalidateAfterFirstRead: truethe session now stays open until the app callsstopSession(). -
iOS:
Nfc#stopSessionno longer submits its Flutter reply twice whenerrorMessageis given (missingreturn), which also invalidated the session twice. -
iOS: an unrecognized tag type left the reader sheet hanging until the 60 s timeout because the completion handler was never called.
-
iOS: starting a session with an unusable polling option reported success while no session had begun; it now returns an
unavailableerror. -
iOS: the tag map is written from the CoreNFC delegate queue and read from the platform thread; access is now serialized.
-
FeliCa.requestSpecificationVersion()invokedFeliCa#requestSpecificationVersionResponse, which no platform implements, so it always threwMissingPluginException. -
onDiscoveredcallbacks that throw no longer leak the native tag handle, and the error is no longer swallowed as an unhandled async error. -
Decoding unknown NDEF type-name-format, MiFare family or error-type values from the platform threw
StateError; these now fall back to theirunknownvariants. Records read off a tag also skip the creation-time format validation, which rejected legitimate chunked records. -
Android: reader mode is now disabled and the tag map cleared on
stopSessionand on activity/engine detach. Reader mode previously stayed active, keeping the NFC radio polling and holding a reference to a destroyed activity. -
Android: an empty or unrecognized
pollingOptionslist produced zero technology flags, which started a session that could never discover a tag. It now falls back to every supported technology.
Documentation #
- Documented the most common iOS setup mistake, found while testing on a device: because
startSessionpollsiso18092by default, CoreNFC rejects the session withMissing required entitlementunlesscom.apple.developer.nfc.readersession.felica.systemcodesis in the app'sInfo.plist. The reader sheet simply never appears, andstartSessionstill completes normally because iOS reports the failure asynchronously -- so an app without anonErrorcallback sees nothing at all. The example now sets the key, passesonErroron every session, and gained a "Tag I/O" button that exercises the tag commands on both platforms.
Changed #
- Android: tag errors distinguish the connect step from the command itself
(
connect: TagLostException: ...), and failures are logged under theNfcUtilPlugintag. A tag that answers discovery but cannot be connected is otherwise indistinguishable from a command that failed. - Android: dropped the leftover debug logging from
startSession. - Android: reader mode sets
FLAG_READER_NO_PLATFORM_SOUNDSand a 250 ms presence-check delay. - Platform value decoding uses constant reverse maps instead of a linear
firstWherescan per record. - Calls whose result is required now raise a
PlatformException(code: 'no_result')instead of force-unwrapping;NfcManager.isAvailable()returnsfalserather than throwing. - iOS: dropped the
@available(iOS 13.0, *)scaffolding, now that the deployment target is 15.6. - CocoaPods builds ship
PrivacyInfo.xcprivacy, matching what Swift Package Manager builds already did.
1.0.3 #
- iOS first scan bug fixed.
1.0.2 #
- Swift Package Manager support
1.0.0 #
- flutter: min 3.32.0
0.1.1 #
- Nfc#disposeTag fixed.
0.1.0 #
- Android and iOS are done.
0.0.1 #
- TODO: Describe initial release.