diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b4905..d60a4f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,7 +177,7 @@ * allow authentication of sector 0 (#157) * fix data type check in `writeBlock` (#161) -## 3.6.0-rc.2 +## 3.6.0-rc.4 This is a release candidate for 3.6.0. Please test it and report any issues. @@ -191,11 +191,5 @@ This is a release candidate for 3.6.0. Please test it and report any issues. * Related issues / PRs: #179 #184, #186, #187 * Now requiring Java 17, Gradle 8.9, MinSDKVer 26, AGP 8.7, Kotlin 2.1.0 * Add Swift package manager support for iOS plugin, bump dependencies - -## 3.6.0-rc.3 - -This is a release candidate for 3.6.0. Please test it and report any issues. - -* All 3.6.0-rc.2 changes are included -* Fix WebUSB interop on Web +* Fix WebUSB interop on Web, add onDisconnect callback * Add support for foreground polling on Android (#16, #179) diff --git a/example/pubspec.lock b/example/pubspec.lock index 2f920ab..c605ce5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -92,7 +92,7 @@ packages: path: ".." relative: true source: path - version: "3.6.0-rc.3" + version: "3.6.0-rc.4" flutter_test: dependency: "direct dev" description: flutter diff --git a/ios/flutter_nfc_kit/Sources/flutter_nfc_kit/FlutterNfcKitPlugin.swift b/ios/flutter_nfc_kit/Sources/flutter_nfc_kit/FlutterNfcKitPlugin.swift index bb5b2e1..3ef6b34 100644 --- a/ios/flutter_nfc_kit/Sources/flutter_nfc_kit/FlutterNfcKitPlugin.swift +++ b/ios/flutter_nfc_kit/Sources/flutter_nfc_kit/FlutterNfcKitPlugin.swift @@ -37,7 +37,7 @@ public class FlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSessionDe var multipleTagMessage: String? public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "flutter_nfc_kit", binaryMessenger: registrar.messenger()) + let channel = FlutterMethodChannel(name: "flutter_nfc_kit/method", binaryMessenger: registrar.messenger()) let instance = FlutterNfcKitPlugin() registrar.addMethodCallDelegate(instance, channel: channel) } diff --git a/lib/webusb_interop.dart b/lib/webusb_interop.dart index e0e5cfa..a0a750d 100644 --- a/lib/webusb_interop.dart +++ b/lib/webusb_interop.dart @@ -56,16 +56,12 @@ extension type _USBControlTransferParameters._(JSObject _) implements JSObject { class WebUSB { static dynamic _device; static String customProbeData = ""; + static Function? onDisconnect; static bool _deviceAvailable() { return _device != null && getProperty(_device, 'opened'); } - static void _onDisconnect() { - _device = null; - log.info('device is disconnected from WebUSB API'); - } - static const USB_PROBE_MAGIC = '_NFC_IM_'; /// Try to poll a WebUSB device according to our protocol. @@ -82,7 +78,10 @@ class WebUSB { promiseToFuture(callMethod(device, 'claimInterface', [1]))) .timeout(Duration(milliseconds: timeout)); _device = device; - _USB.ondisconnect = _onDisconnect.toJS; + _USB.ondisconnect = () { + _device = null; + onDisconnect?.call(); + }.toJS; log.info("WebUSB device opened", _device); } on TimeoutException catch (_) { log.severe("Polling tag timeout"); diff --git a/pubspec.yaml b/pubspec.yaml index 5919544..67e3243 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_nfc_kit description: Provide NFC functionality on Android, iOS & Web, including reading metadata, read & write NDEF records, and transceive layer 3 & 4 data with NFC tags / cards -version: 3.6.0-rc.3 +version: 3.6.0-rc.4 homepage: "https://github.com/nfcim/flutter_nfc_kit" environment: