Skip to content

Commit

Permalink
Merge pull request #151 from rostopira/restart-polling
Browse files Browse the repository at this point in the history
Add "iosRestartPolling" method
  • Loading branch information
Harry-Chen authored Feb 21, 2024
2 parents 55c63e7 + ce8cf35 commit 868c3f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ios/Classes/SwiftFlutterNfcKitPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 7 additions & 0 deletions lib/flutter_nfc_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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].
Expand Down

0 comments on commit 868c3f3

Please sign in to comment.