semlette / nfc_in_flutter

Cross-platform flutter plugin for reading and writing NFC tags. Not maintained anymore - not looking for new maintainer, fork instead.
MIT License
120 stars 119 forks source link

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

Open aventez opened 3 years ago

aventez commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

I think at least for android the necessary code is there. See https://github.com/semlette/nfc_in_flutter/issues/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.

https://github.com/semlette/nfc_in_flutter/blob/8c0550e32d19af82dc482ece65ddb83808003ea4/android/src/main/java/me/andisemler/nfc_in_flutter/NfcInFlutterPlugin.java#L628-L642