Hello everyone.
iOS 16 added ability to connect usb devices. TKSmartCard works well with just a fast command, but if it takes more than 600ms TKSmartCard.transmit fails with communication error -2. Is there a workaround or am I use it wrong?
Usage looks like that:
import CryptoTokenKit
func foo() {
guard let manager = TKSmartCardSlotManager.default else {
return
}
let names = manager.slotNames
let smartCards = names.compactMap { manager.slotNamed($0) }
.filter { $0.state == .validCard }
.compactMap { $0.makeSmartCard() }
guard let card = smartCards.first else {
return
}
let apdu = Data([/*command that lasts longer than 600 ms*/])
Task {
do {
guard try await card.beginSession() else {
print("beginSession failed")
return
}
let res = try await card.transmit(apdu)
print(res.map { String(format: "0x%02X", $0) }.joined(separator: ", "))
} catch {
print(error)
}
}
}