revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.35k stars 317 forks source link

V2Iso15693 invalid tag ID (iOS) #267

Closed Megatron4537 closed 3 years ago

Megatron4537 commented 4 years ago

On Android reading an NfcV (ISO15963 on iOS) tag will return a tag with an id AD3C117E000104E0

reading the same tag on iOS using the V2Iso15963 API to get the tag's ID will return a tag with an id E00401007E113CAD

The same tag is returning two different IDs on each OS. I believe the Android tag ID is correct and wrong on iOS. Interestingly, reversing the ID on iOS is similar, but not exactly, some values are swapped together.

I used the nfc-test-app to verify and the issue is present there too (I copied components react-native-nfc-manager/example/AppV2Iso15693, react-native-nfc-manager/example/AppV2Index, react-native-nfc-manager/example/AppV2 components and added console.log(tag))

method used on Android NfcManager.setEventListener(NfcEvents.DiscoverTag, tag=>tag)

method used on iOS await NfcManager.requestTechnology([NfcTech.Iso15693IOS]); const tag = await NfcManager.getTag();

whitedogg13 commented 4 years ago

Hi @Megatron4537 Nice catch, thanks for reporting this!

I believe its something like endianness issue.

The tag id in native platform is reported as a byte array, and we simply convert it into a hex string one by one, then send back to JS layer. So the issue is because iOS and Android has their id array in reverse order when dealing with 15693 tag.

For example:

It might be an iOS platform bug, but I think it's safer to swap the byte order in your application code for now.

Thanks!

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.