revtel / react-native-nfc-rewriter

NFC open reader app in React Native
MIT License
179 stars 79 forks source link

Documentation Request. #13

Open farry19 opened 3 years ago

farry19 commented 3 years ago

Can you provide the full documentation of the package, as i have gone through the samples but didn't understand how to write custom tags. e.g. vCard or other. Thanks

whitedogg13 commented 3 years ago

Hi @farry19 because this repo is an app, currently we don't have any plan to provide documentation.

Regarding vCard, you can try this code snippet:

async function writeVCard(value) {
  await NfcManager.requestTechnology(NfcTech.Ndef, {
    alertMessage: 'Ready to write some NDEF',
  });

  const {name, tel, org, email} = value;
  const vCard = `BEGIN:VCARD\nVERSION:2.1\nN:;${name}\nORG: ${org}\nTEL;HOME:${tel}\nEMAIL:${email}\nEND:VCARD`;
  const bytes = Ndef.encodeMessage([
    Ndef.record(Ndef.TNF_MIME_MEDIA, 'text/vcard', [], vCard),
  ]);

  await NfcManager.ndefHandler.writeNdefMessage(bytes);
  NfcManager.cancelTechnologyRequest();
}

Hope that helps!

nurfync commented 3 years ago

hi , i want to try this app and clone it , so i have a mifare card, when i try to write a text or mail there is an error pop up like "NFC Error Error: unsupported tag api" why do i get this ? is something wrong about my card?