revtel / react-native-nfc-manager

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

Discrepancy between Android and iOS getTag result #598

Closed erikostling closed 1 year ago

erikostling commented 1 year ago

I'm getting different results when calling getTag on Android vs iOS. Is there any obvious reason behind this? Issue seems related/identical to #450.

Code:

await NfcManager.requestTechnology(NfcTech.Ndef)
const tag = await NfcManager.getTag()

Android:

{
  "canMakeReadOnly":true,
  "id":"046C70F2CB7281",
  "isWritable":true,
  "maxSize":137,
  "ndefMessage":[
    ...
  ],
  "techTypes":[
     "android.nfc.tech.NfcA",
     "android.nfc.tech.MifareUltralight",
     "android.nfc.tech.Ndef"
  ],
  "type":"NFC Forum Type 2"
}

iOS:

{
  "id":"046C70F2CB7281",
  "ndefMessage":[
    ...
  ],
  "tech":"mifare"
}

Expected result:

getTag: () => Promise<TagEvent | null>

...

export interface TagEvent {
  ndefMessage: NdefRecord[];
  maxSize?: number;
  type?: string;
  techTypes?: string[];
  id?: string;
}

Debug info:

react-native: 0.70.2
react-native-nfc-manager: 3.14.1
whitedogg13 commented 1 year ago

Hi @erikostling great question!

Regarding the ugly type TagEvent, it's mainly because:

So rather than putting efforts to make all fields identical in both OS, I only focused on following ones (if they present):

It's simply because In my perspective, id and ndefMessage are the most important fields for most use cases.

github-actions[bot] commented 1 year 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 1 year ago

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

ombogdanJoinToIt commented 1 year ago

why can't I get the ID in the card when I read it from iOS?

ombogdanJoinToIt commented 1 year ago

how to get a tag id on ios. an empty array is now returned. although everything is fine on Android