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

How to solve Tag is not NDEF-compliant? #134

Open
ThomasCarltonInPerson opened this issue Mar 27, 2023 · 2 comments
Open

How to solve Tag is not NDEF-compliant? #134

ThomasCarltonInPerson opened this issue Mar 27, 2023 · 2 comments

Comments

@ThomasCarltonInPerson
Copy link

Hello community,

I'm using Plugin.NFC in a .Net Maui 7 app.

I'm trying to write some NFC cards using the provided code on GitHub.

The code works properly, but Whenever I use a new card, when trying to write something on it, I'm getting the error : Tag is not NDEF-compliant.

Here is my code :

async Task Publish()
{               
    try
    {     
        CrossNFC.Current.StartPublishing(true);
    }
    catch (Exception ex)
    {
        await RaiseError(ex.Message);
    }
}

async void Current_OnTagDiscovered(ITagInfo tagInfo, bool format)
{
    if (!CrossNFC.Current.IsWritingTagSupported)
    {
        await RaiseMessage_("Writing cards is not supported by your device");
        return;
    }
    
    try
    {
        NFCNdefRecord record;

        record = new NFCNdefRecord
        {
            TypeFormat = NFCNdefTypeFormat.Mime,
            MimeType = "application/com.companyname.nfcsample",
            Payload = NFCUtils.EncodeToByteArray("Hithere");
        };

        tagInfo.Records = new[] { record };            
        CrossNFC.Current.PublishMessage(tagInfo, false);
        
    }
    catch (Exception Ex)
    {
        await RaiseError("Writing failed\n" + Ex.Message);            
    }
}

I also noticed that this happens only with new cards. If I take a card and I write something on it using NFC Tools app, then I'm able to write on it using my code. It becomes fully usable on my app.

It seems like there is something I'm missing on the "initialization" of the card.

Does anyone know how to solve that please ?

Thanks.

@alpsware
Copy link

alpsware commented Mar 31, 2023

That is because this plugin is expecting the tag to be already NDEF formatted. If you also want to format non NDEF tags with this plugin, then you should probably have a look here

@Gekidoku
Copy link

Gekidoku commented Sep 21, 2023

Its a few months later but i have the same issue,
Starting a Journey in #144.

I have Security companies as customer and they use NFC tags for their security rounds, both classic and ultralight, although we try to recommend NTAG213 chips.
You can imagine they stick around 20-100 chips in a building depending on the size and they dont want to first format them all and then make them "iOS compliant" (setting the serial key in the ndef message so older ios devices can access it).

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

3 participants