-
Notifications
You must be signed in to change notification settings - Fork 38
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
iOS: How get tag uid? #55
Comments
I have the same problem. Is there any workaround available? This is what I found so far regarding this issue: https://stackoverflow.com/questions/57978507/reading-uids-of-nfc-cards-in-ios-13 Is this maybe related to iOS 13? I tried to read the tag with a different iOS app and it properly shows the uid. |
I started to work on this inspired by the phonegap-nfc plugin: https://github.com/chariotsolutions/phonegap-nfc/blob/master/src/ios/NfcPlugin.m But, being a newbie in NativeScript, I have some issues and I need some help, please. The code can be found here and I have commented what issues I have: I am using demo-ng app. Plugin iOS file is here: https://github.com/demetrius-tech/nativescript-nfc/blob/dev/src/nfc.ios.ts Check tagReaderSessionDidDetectTags() and getTagUID() methods. |
Does anyone know how to translate this Objective C code to TypeScript? id tag = [tags firstObject]; Simply doing: const tag = tags[0]; does not return anything in tag.type Here is what i've done so far: https://github.com/demetrius-tech/nativescript-nfc/blob/dev-uid/src/nfc.ios.ts (tagReaderSessionDidDetectTags() method) |
@demetrius-tech have you tried this? |
@EddyVerbruggen: firstObject only works if I do like this: const tag = NSArray.arrayWithArray(tags).firstObject; otherwise it is not available. Even so, if I do console.log(tag.type) it says "undefined". console.log(tag) outputs "<NFCMiFareTag: 0x282d7e9a0>" Probably more processing is needed on the tags[0] to extract the "type" and after that the "identifier" on the MiFare type. |
Found a way to get the type, I will just compare this: if (NFCTag.prototype.asNFCMiFareTag.apply(tag) === tag) { Next step is to extract the identifier. |
Getting the UID on iOS using NativeScript is not trivial. It always displays empty. Any ideas? My code: https://github.com/demetrius-tech/nativescript-nfc/blob/dev-uid/src/nfc.ios.ts (getTagUID method) Related StackOverflow topics: |
I've managed to get the tag UID by adding native code ObjC library. You can check here: https://github.com/demetrius-tech/nativescript-nfc/tree/dev-ios-write-uid/src Also, you can find there the code for writing tags for iOS. If interested in PR, please let me know. |
Hello demetrius, so you succesfull? can you explain how you did and where i retreive the tag id?
|
@Atomico001: you can find the ObjC code here: https://github.com/demetrius-tech/nativescript-nfc/tree/dev-ios-write-uid/src/platforms/ios/xcode/NfcNativeHelper Created the libNfcNativeHelper.a library and added it to the src/platforms/ios (together with a .d.ts spec) : https://github.com/demetrius-tech/nativescript-nfc/tree/dev-ios-write-uid/src/platforms/ios |
Good job demetrius, so i need to add manually in my platform folder? Any chance you can write a little tutorial to explain which step we need to do? Time to edit your readme :) |
Thanks @Atomico001! I still hope to find a way to avoid using native code. You will find the generic tutorial on how to add native code to NS plug-in here: https://docs.google.com/document/d/1_PDEkC3EtZCsXhthGCmGwtCVVxOwdAepcJaUaA0Uk6k/edit?usp=sharing Please comment if something is not clear or any issues. |
Thanks @demetrius-tech unlucky when i try to install your fork i receive this error when try to start nfc reader:
|
any news? |
I realy need this, someone can help me? |
@Atomico001: I would like to help you but I can't find time. As I mentioned before I created a library in ObjectiveC and imported it to the plug-in. But I am not sure it is the best way, so I am looking for a better way to do this, may be a POD or something. I will try to allocate some time to this soon, will let you know. |
@demetrius-tech nice to see you again. If you can do a working simple demo with your fork i can investigate it and try myself. Unlucky i receive many error when i tried to import your fork. Thanks very much! |
So I tried the same thing as you and was also stuck on the issue that identifier is always null. Then I read this and thanks to your code got it working. Thank you very much!!! |
NfcNdefData should contain the id. In android it work but in iOS it is empty.
Is it possible get the tag uid?
The text was updated successfully, but these errors were encountered: