revtel / react-native-nfc-manager

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

readNdef function doesn't contains NDEF Message. #547

Closed SurpriseMF3000 closed 2 years ago

SurpriseMF3000 commented 2 years ago

Hello, im calling the readNdef() function successful and detect a Tag but the Tag contains a strange NDEF message.

What do I need to do to get from the tag.ndefMessage the raw text value? Which encryption does this tag.ndefMessage has and how can I decrypt it to raw text?

  async function readNdef() {
    try {
      // register for the NFC tag with NDEF in it
      await NfcManager.requestTechnology(NfcTech.Ndef);
      // the resolved tag object will contain `ndefMessage` property
      const tag = await NfcManager.getTag();
      console.warn('Tag found', tag);
      const payload = tag.ndefMessage;
      console.log(payload);

    } catch (ex) {
      console.warn('Oops!', ex);
    } finally {
      // stop the nfc scanning
      NfcManager.cancelTechnologyRequest();
    }
  }

Tag: {"canMakeReadOnly": true, "id": "04EA5002F06E80", "isWritable": true, "maxSize": 492, "ndefMessage": [{"id": "", "payload": [Array], "tnf": 1, "type": [Array]}], "techTypes": ["android.nfc.tech.NfcA", "android.nfc.tech.MifareUltralight", "android.nfc.tech.Ndef"], "type": "NFC Forum Type 2"}

Tag.ndefMessage: [{"id": "", "payload": [2, 101, 110, 73, 116, 194, 180, 115, 32, 119, 111, 114, 107, 105, 110, 103, 32, 77, 111, 116, 104, 101, 114, 102, 117, 99, 107, 101, 114, 115, 33, 33, 33, 32, 89, 101, 115, 115, 115, 115, 115, 115, 115, 59, 41, 32, 66, 97, 109, 109, 109, 109, 109], "tnf": 1, "type": [84]}]

What type is the Tag.ndefMessage?

Thanks for Help;)

SurpriseMF3000 commented 2 years ago

I figured out that the tag.ndefMessage encryption is ASSCI.

chattago2002 commented 1 year ago

I figured out that the tag.ndefMessage encryption is ASSCI.

Hi. Have you solved? I'm trying to get the real message but I can't.

SurpriseMF3000 commented 1 year ago

Hey, you just need to decrypt the ASSCI encrypted payload. You can use decryption libraries/ packages for that. What are you currently working on? DM me via the mentioned email in my profile;)