Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tag UID before Write action #693

Open
cavasinf opened this issue Jan 18, 2024 · 2 comments
Open

Get tag UID before Write action #693

cavasinf opened this issue Jan 18, 2024 · 2 comments

Comments

@cavasinf
Copy link

cavasinf commented Jan 18, 2024

Is it possible to read and write at the same time and check the UID before writing?

I've tried this, but the id is empty:

NfcManager.requestTechnology(NfcTech.Ndef)
  .then(() => {
    // return NfcManager.getTag() // <-- If this is use, it double the NFC prompt with possible `cancelTechnologyRequest` call missing
    return NfcManager.ndefHandler.getNdefMessage()
  })
  .then((tag) => {
    console.log(tag?.id) // Result is null

    // <---- I want to check the UID here

    const bytes = Ndef.encodeMessage([Ndef.textRecord("Hello")])
    return NfcManager.ndefHandler.writeNdefMessage(bytes)
  })
  .then(() => {
    if (Platform.OS === "ios") {
      NfcManager.setAlertMessageIOS("Written")
    }
  })
  .finally(() => NfcManager.cancelTechnologyRequest())
Copy link

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 github-actions bot added the Stale label Apr 18, 2024
@cavasinf
Copy link
Author

Get out of here!

@github-actions github-actions bot removed the Stale label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant