react-native-nfc-manager
react-native-nfc-manager copied to clipboard
Get tag UID before Write action
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())
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.
Get out of here!
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.
Get out of here!