Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Is there any way to NDEF format NFC tag? #84

Open
aventez opened this issue Mar 21, 2021 · 2 comments
Open

Is there any way to NDEF format NFC tag? #84

aventez opened this issue Mar 21, 2021 · 2 comments

Comments

@aventez
Copy link

aventez commented Mar 21, 2021

My question is how can I NDEF format the empty NFC tag in Flutter? Currently, I'm using this lib, but it only supports already NDEF formatted tags. Any ideas how to solve that?

Here is my code.

NDEFMessage newMessage = NDEFMessage.withRecords([
  NDEFRecord.uri(path),
]);

Stream<NDEFTag> stream = NFC.writeNDEF(newMessage, once: true);
stream.listen((NDEFTag tag) {
  showNotification(context, 'NFC Tag was activated.');
});

Thanks in advance!

@ZippyRainbow
Copy link

@aventez I don't believe the function to format a tag to NDEF exists in the code. Would need to be developed as an option.

@guenth39
Copy link

guenth39 commented May 20, 2021

I think at least for android the necessary code is there. See #84
for more information. No idea if it works. I do not know how to format a tag differently for testing 😄 But new Tags are working for me on Android but not on iOS, so probably it's working.

} else if (formatable != null) {
FormatTask task = new FormatTask();
FormatRequest request = new FormatRequest(formatable, message);
try {
NfcInFlutterException result = task.execute(request).get();
if (result != null) {
throw result;
}
} catch (ExecutionException e) {
// TODO
throw new NfcInFlutterException("ExecutionError", e.getMessage(), null);
} catch (InterruptedException e) {
// TODO
throw new NfcInFlutterException("InterruptedException", e.getMessage(), null);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants