appidea / react-native-hce

Emulate smart cards inside React-Native application.
MIT License
64 stars 26 forks source link

Can't read an NFC tag #38

Open Henry-E opened 1 month ago

Henry-E commented 1 month ago

Hi,

I'm testing out this library using expo. I've added all the necessary lines to the manifest and the aid_list.xml file.

But I'm still having a lot trouble getting the example app working. Clearly something is working, the app doesn't crash when it attempts to turn on HCE and when I have two different HCE apps running, the android UI pops up and asks which app should be responsible for generating the tag. The only issue is that the other app actually generates a tag that can be read and the example doesn't.

The most frustrating part is the difficulty in debugging or trying to narrow down what's going wrong. It's using all the same example code and the manifest + aid_list have been added / updated. The HCE logger detects when the HCE is turned on and off, it detects when another tag is read. But it never actually generates the tag or the data from it.

In the event when there are two apps with HCE on the phone both active, the android UI asks to choice between them. When I choose the other app the nfc reader on the other phone detects the tag. When I choose the react-native-hce example app the UI for tapping the phone against a card reader shows up but the tag reader can never detect the generated tag. In the event that only the react-native-hce app is active, then no android options show up and the tag is still never read.

For reference here's the working app, which at least proves that my devices can do HCE with other devices correctly. https://github.com/MichaelsPlayground/NfcHceNdefEmulator/tree/master.

But I have no idea

Appreciate any help possible

Henry-E commented 1 month ago

My best guess is that it's linked to the array size issue mentioned on SE and another issue. https://stackoverflow.com/questions/75932985/why-does-data-transfer-over-nfc-with-hce-only-work-with-android-lower-12

Is it at all possible to merge or test this change to reduce the size of the max data?

I've been trying to run the code from this repo to test changes locally but keep running into errors and stuff that's out of date.

appidea commented 1 month ago

Hi Henry,

I am going to publish the new version of this library soon, taking into account part of the issues that are on the board. The issue You've mentioned is one of these. There is generally a lot of legacy stuff to be changed or removed.

Please follow the repo to be notified about the update.

Br, mat

Henry-E commented 1 month ago

Awesome, thanks for the update mat.

I can possibly help to test with integrating the expo plugin file that wodin wrote once I can get the code in this repo running. I'm still a bit of a noob at this react native and gradle stuff but the plugin file wodin wrote seems to create working versions of the correct aid list xml and android manifest files, making it super easy to use react-native-hce in an expo app.