From ce8cf350745c4fc167fe1b6c1e34fbfe99076394 Mon Sep 17 00:00:00 2001 From: rostopira Date: Wed, 21 Feb 2024 15:08:45 +0200 Subject: [PATCH] Add "iosRestartPolling" method --- ios/Classes/SwiftFlutterNfcKitPlugin.swift | 7 +++++++ lib/flutter_nfc_kit.dart | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ios/Classes/SwiftFlutterNfcKitPlugin.swift b/ios/Classes/SwiftFlutterNfcKitPlugin.swift index 56fe074..cb7f73e 100644 --- a/ios/Classes/SwiftFlutterNfcKitPlugin.swift +++ b/ios/Classes/SwiftFlutterNfcKitPlugin.swift @@ -50,6 +50,13 @@ public class SwiftFlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSess } else { result("not_supported") } + } else if call.method == "restartPolling" { + if let session = session { + self.result = result + session.restartPolling() + } else { + result(FlutterError(code: "404", message: "No active session", details: nil)) + } } else if call.method == "poll" { if session != nil { result(FlutterError(code: "406", message: "Cannot invoke poll in a active session", details: nil)) diff --git a/lib/flutter_nfc_kit.dart b/lib/flutter_nfc_kit.dart index 22ca0bb..a4c98f9 100644 --- a/lib/flutter_nfc_kit.dart +++ b/lib/flutter_nfc_kit.dart @@ -343,6 +343,13 @@ class FlutterNfcKit { return NFCTag.fromJson(jsonDecode(data)); } + /// Works only on iOS + /// Calls NFCTagReaderSession.restartPolling() + /// Call this if you have received "Tag connection lost" exception + /// This will allow to reconnect to tag without closing system popup + static Future iosRestartPolling() async => + await _channel.invokeMethod("restartPolling"); + /// Transceive data with the card / tag in the format of APDU (iso7816) or raw commands (other technologies). /// The [capdu] can be either of type Uint8List or hex string. /// Return value will be in the same type of [capdu].