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

Display of UID and TagType #16

Open
erikm30 opened this issue Sep 21, 2017 · 27 comments
Open

Display of UID and TagType #16

erikm30 opened this issue Sep 21, 2017 · 27 comments

Comments

@erikm30
Copy link

erikm30 commented Sep 21, 2017

Some apps, namely NFC Tools from wakdev and NFC NDEF READER https://itunes.apple.com/us/app/nfc-ndef-reader/id1286248064?mt=8 manage to show UID and TagType - see screenshots.
Any idea how to access these properties ?

@scottire
Copy link

scottire commented Sep 22, 2017

UUID is possible by using the array foundTags from the session in
- (void) readerSession:(nonnull NFCNDEFReaderSession *)session didDetectNDEFs:(nonnull NSArray<NFCNDEFMessage *> *)messages

NSArray *foundTags = [session valueForKey:@"_foundTags"];
NSObject *tag = foundTags[0];
NSData *uuid = [tag valueForKey:@"_tagID"];

Accessing these is potentially insecure so best to have some verification in place with each valueForKey and accessed array.
I don't know if it's possible without doing sketchy access to these instance variables yet.

screen shot 2017-09-22 at 09 17 19

I don't have enough tags to get all the Tag Types, but there is an enum type beside tagID and from the CoreNFC header files it says that NFC Forum Tag type 1 to 5 that is NDEF formatted are supported.

@ttraub
Copy link

ttraub commented Oct 9, 2017

[EDITED] Thank you! That works. The _tagID value agrees with TagInfo and OmniKey Reader (initially I posted it didn't work, sorry)

@hansemannn
Copy link
Owner

I'll add it to the visual example, thanks!

@scottire
Copy link

@hansemannn
Copy link
Owner

The problem is that it looks like a private API and Apple will likely reject apps using that API. So besides the fact that the phonegap-PR might not get merged, I'm not sure if we should expose it as a best practice. Still wondering how the above apps got through review with that - probably obfuscated the call or Apple didn't catch it.

@Swati2707
Copy link

Swati2707 commented Oct 31, 2017

Hello,
I have been trying to read tag's UID with the sample app you provided. But its unable to read an empty tag's UID. My complete project is based on UID and I am unable to sort it out. https://drive.google.com/open?id=0B5RBua-pcqKwNzNUcVl5eXl0YXM

@scottire
Copy link

Apple will in fact reject an app that uses this private api. As for why you can’t read a non-ndef formatted tag, it’s because CoreNFC only detect tags that have properly formatted NDEF data.

@Swati2707
Copy link

Thank you. Let me find a way to encode it in some other way.

@Swati2707
Copy link

Hello,
Well my client is getting his tag NDEF encoded with URL. I haven't received the tags yet. But I have to confirm if i will be able to read the UID of those tags. As I have noticed NXP app and want to know more about it. Can anyone help?

@erikm30
Copy link
Author

erikm30 commented Nov 6, 2017 via email

@Swati2707
Copy link

Hey. Thank you so much erikm30.

@kkscwcd
Copy link

kkscwcd commented Nov 16, 2017

@erikm30
I am trying the same things but getting only payload and ID is always coming blank in my APP . When i used the NXP from Itunes store it read the ID . Can you please share the code for this which you mentioned above .

You can use the NDEF itself to transfer ("Mirror") the UID to the phone. (i.e. encode https://your.customer.com/some_path/uid/ resp. https://your.customer.com/some_path?uid=xx..xx). In case of NTAG 213 and other NXP tags, you can encode even "00..00" for all tags and let the mirror feature do the job of displaying the actual tag UID.

Please share some code for mirroring features so i can understand.

@erikm30
Copy link
Author

erikm30 commented Nov 16, 2017 via email

@cloudfirst
Copy link

@erikm30
Why next release of NXP TagInfo App will remove the ID from being displayed ?
for using the non-public API to read tagid ?

@andyden9
Copy link

andyden9 commented Dec 21, 2017

I tested, iOS 11.2 has been removed _tagID data and _UID is changing last 4 bytes every time you read NFC tag, and it's not UID at all (I guess it's encrypted). I didn't find any other private API that relates to uid.

@zipnfc
Copy link

zipnfc commented Jan 7, 2018

We did have UID and types in our IOS NFC app but we have noticed since the latest build 11.2 on the iPhone these values are being suppressed. Hopefully one day they will just support it in the API. Our current version of PROX NFC Tag just shows unavailable so will remove on the next version until they appear again.

@YZahringer
Copy link

@zipnfc
Copy link

zipnfc commented Jun 6, 2018 via email

@YZahringer
Copy link

@zipnfc
Copy link

zipnfc commented Jun 4, 2019 via email

@scottire
Copy link

scottire commented Jun 6, 2019

As for why you can’t read a non-ndef formatted tag, it’s because CoreNFC only detect tags that have properly formatted NDEF data.

This is no longer true with iOS 13! The ability to send APDUs to MIFARE and FeliCa tags (or any tags that conform to ISO 15693 or ISO 7816) means you can manually read data from these tags. Another exciting update is the ability to read Value Added Service (VAS) tags.

Looks like UID and writing will be available

There's an identifier field on some of the tag types which is very likely (need to test to be sure) the UID (see here).
As for writing, see this new official tutorial for an example of writing a tag with NDEF formatted data.

@YZahringer
Copy link

WWDC 19 Core NFC Enhancements session: https://developer.apple.com/videos/play/wwdc2019/715/

@lyl155
Copy link

lyl155 commented Sep 3, 2019

How do I read the tag's uid

@Dev-
Copy link

Dev- commented Sep 18, 2019

Does anyone know how to actually achive this in iOS 13?

I see lots of posts and statements from Apple and other commentators thats it's possible but I've not seen any implementation in code.

https://stackoverflow.com/questions/57978507/reading-uids-of-nfc-cards-in-ios-13

@scottire
Copy link

scottire commented Sep 18, 2019

How do I read the tag's uid

Assuming the tag is a not a NFCFeliCaTag, it is available in the identifier property of the tag object.

func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {      
  if case let NFCTag.miFare(tag) = tags.first! {
    print(tag.identifier as NSData)
  }
}

@krevelen
Copy link

@erikm30 @hansemannn @scottire did any of you happen to try reading the UID from a MIFARE Classic (emulation) tag with iOS13 yet? I was able to confirm the new support for the DESfire and UltraLight ICs in the MIFARE Family, but for various MIFARE Classic ICs (the unknown family member?) my Console shows different error types. Would private APIs perhaps be helpful here, e.g. to intercept and amend the discovery polling routine?

  1. an Infineon Classic 4k Emulation actually logs 1 tags found with the correct UID (31:9A:2F:88), ATQA (0x0200), SAK (0x20 and 0x18, both included in the actual value: 0x38) and tag type (both Generic 4A and MiFare detected), but then throws a Stack Error:

    error	14:48:08.675369 +0200	nfcd	00000001 04e04390 -
        [NFDriverWrapper connectTag:]:1436  Failed to connect to tag: 
        <NFTagInternal: 0x104e05cd0>-{length = 8, bytes = 0x7bad030077180efa} 
        { Tech=A Type=Generic 4A ID={length = 4, bytes = 0x319a2f88} 
        SAK={length = 1, bytes = 0x20} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
    :
    error	14:48:08.682881 +0200	nfcd	00000001 04e04390 -
        [NFDriverWrapper connectTag:]:1436  Failed to connect to tag: 
        <NFTagInternal: 0x104e1d600>-{length = 8, bytes = 0x81ad0300984374f3} 
        { Tech=A Type=MiFare ID={length = 4, bytes = 0x319a2f88} 
        SAK={length = 1, bytes = 0x18} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
    :
    default	14:48:08.683150 +0200	nfcd	00000001 04e07470 -
        [_NFReaderSession handleRemoteTagsDetected:]:445  1 tags found
    default	14:48:08.685792 +0200	nfcd	00000001 04e07470 -
        [_NFReaderSession connect:callback:]:507  NFC-Example
    :
    error	14:48:08.693429 +0200	nfcd	00000001 04e04390 -
        [NFDriverWrapper connectTag:]:1436  Failed to connect to tag: 
        <NFTagInternal: 0x104e05cd0>-{length = 8, bytes = 0x81ad0300984374f3} 
        { Tech=A Type=MiFare ID={length = 4, bytes = 0x319a2f88} 
        SAK=(null) ATQA=(null) historicalBytes={length = 0, bytes = 0x}}
    :
    error	14:48:08.694019 +0200	NFC-Example	00000002 802e2700 -
        [NFCTagReaderSession _connectTag:error:]:568  Error 
        Domain=NFCError Code=100 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x2822a86c0 
        {Error Domain=nfcd Code=15 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error}}}
    
  2. an NXP SmartMX (Classic 4k emulation) with UID CF:3E:40:04 is discovered initially, but a reception error during ISO 14443-4A presence check (Proc Iso-Dep pres chk ntf: Receiption failed) continuously restarts the discovery polling until the session finally expires:

    error	10:44:50.650673 +0200	nfcd	Proc Iso-Dep pres chk ntf: Receiption failed
    :
    error	10:44:50.677470 +0200	nfcd	00000001 04e04390 -
        [NFDriverWrapper disconnectTag:tagRemovalDetect:]:1448  Failed to disconnect tag: 
        <NFTagInternal: 0x104f09930>-{length = 8, bytes = 0x07320d00f3041861} 
        { Tech=A Type=Generic 4A ID={length = 4, bytes = 0xcf3e4004} 
        SAK={length = 1, bytes = 0x20} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
    default	10:44:50.677682 +0200	nfcd	00000001 04e04390 -
        [NFDriverWrapper restartDiscovery]:1953
    
  3. an actual NXP Classic 4k with UID 2D:FE:9B:87 remains undetected and throws no error. This one simply times out after 60 seconds and logs the last 128 discovery messages transmitted (Tx) and received (Rx), among which the following pattern is repeated (I'm assuming REQA and ATQA messages?):

    error	11:42:19.511354 +0200	nfcd	1571305339.350902 Tx  '21 03 07 03 FF 01 00 01 01 01 6F 61'
    error	11:42:19.511484 +0200	nfcd	1571305339.353416 Rx  '41 03 01'
    error	11:42:19.511631 +0200	nfcd	1571305339.353486 Rx  '00 F6 89'
    error	11:42:19.511755 +0200	nfcd	1571305339.362455 Rx  '61 05 14'
    error	11:42:19.511905 +0200	nfcd	1571305339.362529 Rx  '01 80 80 00 FF 01 09 02 00 04 2D FE 9B 87 01 18 00 00 00 00 2D 11'
    
    error	11:42:19.512152 +0200	nfcd	1571305339.362734 Tx  '21 06 01 00 44 AB'
    error	11:42:19.512323 +0200	nfcd	1571305339.363959 Rx  '41 06 01'
    error	11:42:19.512489 +0200	nfcd	1571305339.364028 Rx  '00 1D 79'
    error	11:42:19.512726 +0200	nfcd	1571305339.364300 Rx  '61 06 02'
    error	11:42:19.512914 +0200	nfcd	1571305339.364347 Rx  '00 00 EB 78'
    

@vinksharma
Copy link

vinksharma commented Nov 3, 2020

As per my findings ->
UID is still accessible if you're using 'NFCTagReaderSession' and inaccessible using 'NFCNdefReaderSession' .

Few tags can't be read/detected using 'NFCTagReaderSession', but the TAGs which are readable using NFCTagReaderSession should be able to read and detect UID
class NFCTagReaderSession --- A reader session for detecting ISO7816, ISO15693, FeliCa, and MIFARE tags.

Reader Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests