swift - 使用iOS13无法读取ePassport的NFC芯片
问题描述
import UIKit
import CoreNFC
class ViewController: UIViewController, NFCTagReaderSessionDelegate {
var nfcTagReaderSession: NFCTagReaderSession?
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("Tag reader did become active")
print("isReady: \(nfcTagReaderSession?.isReady)")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print("\(error)")
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
// this part is never called!
print("got a Tag!")
print("\(tags)")
}
@IBAction func clickedNFC(_ sender: Any) {
nfcTagReaderSession = NFCTagReaderSession(pollingOption: [.iso14443], delegate: self)
nfcTagReaderSession?.alertMessage = "Place the device on the innercover of the passport"
nfcTagReaderSession?.begin()
print("isReady: \(nfcTagReaderSession?.isReady)")
}
}
我的权利文件中也有
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
<string>TAG</string>
</array>
在我的 Info.plist
<key>NFCReaderUsageDescription</key>
<string>Read the NFC chip of ePassports</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
</array>
我的问题是tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag])
永远不会被调用。我错过了什么?
解决方案
我在 Info.plist 中找到了添加00000000000000
到com.apple.developer.nfc.readersession.iso7816.select-identifiers
条目中的解决方案现在它看起来像这样:
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>00000000000000</string>
</array>
推荐阅读
- entity-framework-core - 如何使用 Entity Framework Core 自定义迁移历史记录表
- c++ - 如何在节点中返回数据?
- vb.net - VB.Net 搜索文本并替换为文件内容
- java - 将 0x00 等 unicode 字符转换为字节
- python - 在工具提示的范围内显示一个值
- php - 如何使用另一个多对多关系模型技能/级别扩展用户模型?
- angular - 如何在api中传递id
- node.js - 由lovell/sharp模块引起的AWS Elasticbeanstalk升级问题
- php - 交换一个使用PHP
- python - 在 fastcomet 上设置 python 应用程序