Sea*_*Dev 5 nfc ios mifare core-nfc
I would like to retrive the UID of MiFare cards. I'm using an iPhone X, Xcode 11 and iOS 13.
I'm aware this wasn't possible (specifically reading the UID) until iOS 13 according to this website: https://gototags.com/blog/apple-expands-nfc-on-iphone-in-ios-13/ and this guy: https://www.reddit.com/r/apple/comments/c0gzf0/clearing_up_misunderstandings_and/
The phones NFC reader is correctly detecting the card however the unique identifier is always returned as empty or nil. I can read the payload however and irrelvant to iOS but I can do this in Android (confirms the card isn't faulty or just odd)
Apple Sample Project: https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if case let NFCTag.miFare(tag) = tags.first! {
session.connect(to: tags.first!) { (error: Error?) in
let apdu = NFCISO7816APDU(instructionClass: 0, instructionCode: 0xB0, p1Parameter: 0, p2Parameter: 0, data: Data(), expectedResponseLength: 16)
tag.queryNDEFStatus(completionHandler: {(status: NFCNDEFStatus, e: Int, error: Error?) in
debugPrint("\(status) \(e) \(error)")
})
tag.sendMiFareISO7816Command(apdu) { (data, sw1, sw2, error) in
debugPrint(data)
debugPrint(error)
debugPrint(tag.identifier)
debugPrint(String(data: tag.identifier, encoding: .utf8))
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
I'm aware these sorts of hacks: CoreNFC not reading UID in iOS
But they are closed and only apply to iOS 11 for a short time in the past.
我知道你说过它会回来,nil
但为了让未来的读者清楚:
假设它不是 Felica 标签,那么identifier
当检测到它时它应该在现场:
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if case let NFCTag.miFare(tag) = tags.first! {
print(tag.identifier as NSData)
}
}
Run Code Online (Sandbox Code Playgroud)
但就您而言,它是空的(请参阅下面的编辑)。对于大多数标签,获取标签 UID 的 APDU 是
0xff // Class
0xca // INS
0x00 // P1
0x00 // P2
0x00 // Le
Run Code Online (Sandbox Code Playgroud)
所以你可以尝试使用tag.sendMiFareCommand
手动发送该命令。
编辑:OP 的响应,它不是空的,但不清楚,因为在 Swift 中打印数据不会显示在控制台中
归档时间: |
|
查看次数: |
1105 次 |
最近记录: |