Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "iosRestartPolling" method #151

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading