您好,我按照UG10045.pdf 的说明创建了 iOS 应用程序。我创建了 ApduExchangeWithByteArray 方法并实现了其内容。但是,当将标签的响应发送回 Taplinx 库时,应用程序崩溃了,设备日志中显示以下内容:
Time Device Name Type PID Tag Message
Nov 6 20:44:31 iPhone Notice 5223 MobileFacilityApp Command Set - 1
Nov 6 20:44:31 iPhone Notice 5223 MobileFacilityApp Command Set - Native
Nov 6 20:44:31 iPhone Error 0 kernel(Sandbox) Sandbox: MobileFacilityApp(5223) deny(1) sysctl-read kern.bootargs
Nov 6 20:44:38 iPhone Notice 5223 MobileFacilityApp(UIKitCore) Received memory warning.
Nov 6 20:44:38 iPhone Notice 5223 MobileFacilityApp(UIKitCore) Received memory warning.
Nov 6 20:44:40 iPhone Notice 0 kernel EXC_RESOURCE -> MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)
Nov 6 20:44:40 iPhone Notice 0 kernel memorystatus: killing process 5223 [MobileFacilityApp] in high band FOREGROUND (100) - memorystatus_available_pages: 44859当我将空响应发回 taplinx 库(仅 TL_TagAPDUResponse 而未设置 ResponseData)时 - 应用程序不会崩溃,并且我收到有关响应不完整的错误(这是预期的)。我做错了什么?
@ukcas - taplinx ios 库的哪个版本是“当前”版本?因为我使用的是 2.0.0 版本,当我从 apduExchange 方法返回 TL_TagAPDUResponse 时,它肯定会崩溃,所以它必须是 j2objc 库中的原始 IOSByteArray。我正在使用 taplinx 库的 c# 绑定,但这在这个问题上无关紧要。
你好,达米安,
也许错误的原因是由于超出了内存限制而不是 TapLinx 库?
MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)
集成TapLinx库的应用程序可以按如下方式使用(无需在顶层实现ApduExchange)
将委托设置为 APDUHandler
let reader = TL_IOSNFCReader(uid: tag.identifier, historicalBytes: tag.historicalBytes ?? Data())
handler = TapLinxApduHandler(reader: reader)
handler.delegate = self
libraryManager?.setApduHandlerWithApduHandler(handler)
下一步是在应用程序内部实现协议方法
func apduExchange(withByteArray apduData: Data) -> TL_TagAPDUResponse? {
var tagAPDUResponse: TL_TagAPDUResponse?
if connectedTag != nil {
// Send Tag Type Native of ISO and the apdu as NFCISO7816APDU
executeAPDUCommandOn7816Tag(tagType: tagtype, apdu: apdu) { data in
let appendedData = data
tagAPDUResponse = TL_TagAPDUResponse(responseData: appendedData, tag: self.currentTag)
semaphore.signal()
}
let _ = semaphore.wait(timeout: .now() + 3.0)
} else if connectedMifareTag != nil {
let semaphore = DispatchSemaphore(value: 0)
print("MIFARE CAPDU -> \(apduData.hex)")
executeAPDUCommandOnMIFARETag(apdu: apduData) { data in
print("RAPDU <- Data: \(data.hex)")
tagAPDUResponse = TL_TagAPDUResponse(responseData: data, tag: self.currentTag)
semaphore.signal()
}
let _ = semaphore.wait(timeout: .now() + 3.0)
}
print("Tag Response \(String(describing: tagAPDUResponse))")
return tagAPDUResponse
}
希望这种简化能对您有所帮助。
顺祝商祺!
TapLinx团队
还有一件事 - apduData 实际上也是 IOSByteArray,而不是 NSData
显然 TapLinx-v2.0.0 中包含的标题都是错误的。在TapLinxApduHandler.h中我们看到声明:
- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;但实际上我们应该返回 IOSByteArray*,否则应用程序将崩溃并出现上述症状