Giter Site home page Giter Site logo

franckbour / plugin.nfc Goto Github PK

View Code? Open in Web Editor NEW
227.0 17.0 67.0 1.19 MB

A Cross-Platform NFC (Near Field Communication) plugin to easily read and write NFC tags in your application.

License: MIT License

C# 100.00%
xamarin xamarin-forms dotnet xamarin-android xamarin-ios nfc ndef dotnet-maui maui

plugin.nfc's Introduction

NFC logo Plugin.NFC

A Cross-Platform NFC (Near Field Communication) plugin to easily read and write NFC tags in your Xamarin Forms or .NET MAUI applications.

This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty between NFC devices, tag types, and operating systems.

Status

Package Build NuGet MyGet
Plugin.NFC Build status Nuget MyGet

CI Feed : https://www.myget.org/F/plugin-nfc/api/v3/index.json

Supported Platforms

Platform Version Tested on
Android 4.4+ Google Nexus 5, Huawei Mate 10 Pro, Google Pixel 4a, Google Pixel 6a
iOS 11+ iPhone 7, iPhone 8

Windows, Mac and Linux are currently not supported. Pull Requests are welcomed!

Setup

Android Specific

  • Add NFC Permission android.permission.NFC and NFC feature android.hardware.nfc in your AndroidManifest.xml
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />
  • Add the line CrossNFC.Init(this) in your OnCreate()
protected override void OnCreate(Bundle savedInstanceState)
{
    // Plugin NFC: Initialization before base.OnCreate(...) (Important on .NET MAUI)
    CrossNFC.Init(this);

    base.OnCreate(savedInstanceState);
    [...]
}
  • Add the line CrossNFC.OnResume() in your OnResume()
protected override void OnResume()
{
    base.OnResume();

    // Plugin NFC: Restart NFC listening on resume (needed for Android 10+) 
    CrossNFC.OnResume();
}
  • Add the line CrossNFC.OnNewIntent(intent) in your OnNewIntent()
protected override void OnNewIntent(Intent intent)
{
    base.OnNewIntent(intent);

    // Plugin NFC: Tag Discovery Interception
    CrossNFC.OnNewIntent(intent);
}

iOS Specific

iOS 13+ is required for writing tags.

An iPhone 7+ and iOS 11+ are required in order to use NFC with iOS devices.

  • Add Near Field Communication Tag Reading capabilty in your Entitlements.plist
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
    <string>NDEF</string>
    <string>TAG</string>
</array>
  • Add a NFC feature description in your Info.plist
<key>NFCReaderUsageDescription</key>
<string>NFC tag to read NDEF messages into the application</string>
  • Add these lines in your Info.plist if you want to interact with ISO 7816 compatible tags
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<string>com.apple.developer.nfc.readersession.iso7816.select-identifiers</string>
  • Add these lines in your Info.plist if you want to interact with Mifare Desfire EV3 compatible tags
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>com.apple.developer.nfc.readersession.iso7816.select-identifiers</string>
    <string>D2760000850100</string>
</array>

iOS Considerations

If you are having issues reading Mifare Classic 1K cards - the chances are the issue is not with this library, but with Apple's API.

On iOS 11, apple released the ability to READ NFC NDEF data only using the NfcNdefReaderSession API (https://developer.apple.com/documentation/corenfc/nfcndefreadersession)

A Mifare Classic 1K card will scan if there is a valid NDEF record on it. A blank card will not scan.

In iOS 11, it was not possible to obtain the CSN (serial number/identity) from NFC tags/card.

With iOS 13, along came the ability to write NDEF data AND read serial numbers. However, rather then adapting the NfcNdefReaderSession API, Apple created a NEW API called NfcTagReaderSession (https://developer.apple.com/documentation/corenfc/nfctagreadersession) and left the old NfcNdefReaderSession API untouched.

The new NfcTagReaderSession API in iOS 13 no longer supports Mifare Classic 1K cards period. No idea why - but if you look at Apple's Dev Forums multiple people have spotted the same thing.

So even if you have a Mifare Classic 1K card which reads fine with the old iOS 11 NfcNdefReaderSession API, that same card will not even scan with iOS 13's NfcTagReaderSession API.

If you need to read NDEF data off of a Mifare Classic 1K card, then you can:

  • use version 0.1.11 of this library as it was written with the NfcNdefReaderSession API.
  • use CrossNFC.Legacy from 0.1.20+ which allow you to switch between NfcTagReaderSession and NfcNdefReaderSession on-the-fly.

Unfortunately, even with iOS 13, it seems there is no way to read the serial number / CSN off of a Mifare Classic 1K card.

API Usage

Before to use the plugin, please check if NFC feature is supported by the platform using CrossNFC.IsSupported.

To get the current platform implementation of the plugin, please call CrossNFC.Current:

  • Check CrossNFC.Current.IsAvailable to verify if NFC is available.
  • Check CrossNFC.Current.IsEnabled to verify if NFC is enabled.
  • Register events:
// Event raised when a ndef message is received.
CrossNFC.Current.OnMessageReceived += Current_OnMessageReceived;
// Event raised when a ndef message has been published.
CrossNFC.Current.OnMessagePublished += Current_OnMessagePublished;
// Event raised when a tag is discovered. Used for publishing.
CrossNFC.Current.OnTagDiscovered += Current_OnTagDiscovered;
// Event raised when NFC listener status changed
CrossNFC.Current.OnTagListeningStatusChanged += Current_OnTagListeningStatusChanged;

// Android Only:
// Event raised when NFC state has changed.
CrossNFC.Current.OnNfcStatusChanged += Current_OnNfcStatusChanged;

// iOS Only: 
// Event raised when a user cancelled NFC session.
CrossNFC.Current.OniOSReadingSessionCancelled += Current_OniOSReadingSessionCancelled;

Launch app when a compatible tag is detected on Android

In Android, you can use IntentFilter attribute on your MainActivity to initialize tag listening.

[IntentFilter(new[] { NfcAdapter.ActionNdefDiscovered }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "application/com.companyname.yourapp")]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity 
{
    ...
}

To launch/open an app with a tag, TypeFormat of the record must be set to NFCNdefTypeFormat.Mime and MimeType should be setted to the same value of IntentFilter.DataMimeType (e.g. application/com.companyname.yourapp):

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

Read a tag

  • Start listening with CrossNFC.Current.StartListening().
  • When a NDEF message is received, the event OnMessageReceived is raised.

Write a tag

  • To write a tag, call CrossNFC.Current.StartPublishing()
  • Then CrossNFC.Current.PublishMessage(ITagInfo) when OnTagDiscovered event is raised.
  • Do not forget to call CrossNFC.Current.StopPublishing() once the tag has been written.

Clear a tag

  • To clear a tag, call CrossNFC.Current.StartPublishing(clearMessage: true)
  • Then CrossNFC.Current.PublishMessage(ITagInfo) when OnTagDiscovered event is raised.
  • Do not forget to call CrossNFC.Current.StopPublishing() once the tag has been cleared.

For more examples, see sample application in the repository.

Customizing UI messages

  • Set a new NfcConfiguration object to CrossNFC.Current with SetConfiguration(NfcConfiguration cfg) method like below
// Custom NFC configuration (ex. UI messages in French)
CrossNFC.Current.SetConfiguration(new NfcConfiguration
{
    Messages = new UserDefinedMessages
    {
        NFCSessionInvalidated = "Session invalidée",
        NFCSessionInvalidatedButton = "OK",
        NFCWritingNotSupported = "L'écriture des TAGs NFC n'est pas supporté sur cet appareil",
        NFCDialogAlertMessage = "Approchez votre appareil du tag NFC",
        NFCErrorRead = "Erreur de lecture. Veuillez rééssayer",
        NFCErrorEmptyTag = "Ce tag est vide",
        NFCErrorReadOnlyTag = "Ce tag n'est pas accessible en écriture",
        NFCErrorCapacityTag = "La capacité de ce TAG est trop basse",
        NFCErrorMissingTag = "Aucun tag trouvé",
        NFCErrorMissingTagInfo = "Aucune information à écrire sur le tag",
        NFCErrorNotSupportedTag = "Ce tag n'est pas supporté",
        NFCErrorNotCompliantTag = "Ce tag n'est pas compatible NDEF",
        NFCErrorWrite = "Aucune information à écrire sur le tag",
        NFCSuccessRead = "Lecture réussie",
        NFCSuccessWrite = "Ecriture réussie",
        NFCSuccessClear = "Effaçage réussi"
    }
});

Tutorials

Thanks to Saamer Mansoor (@saamerm) who wrote this excellent article on Medium about Plugin.NFC and how to use it, check it out!

He also made this video:

NFC apps on iOS & Android using Xamarin Forms or Native

Contributing

Feel free to contribute. PRs are accepted and welcomed.

Credits

Inspired by the great work of many developers. Many thanks to:

plugin.nfc's People

Contributors

danielmeza avatar evgenyvalavin avatar f-richter avatar franckbour avatar hyshai avatar pavan7parekh avatar saamerm avatar sborghini avatar zlordzachy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin.nfc's Issues

Scanning EU Passport Support iOS

Description

My iPhone cant detect the NFC tag on my passport. Is there any additional configuration i need to make or does the library not support scanning passports?

"For getting access to the chip, the same combination of document number, birthdate and expiry date is used as password. Additionally, the chip can accept one or more Card Access Numbers (CAN) as a password. Typically, a CAN is only 6 digits long and is printed on the document, like the Machine-Readable Zone."

Is there anywhere we can pass data in to the NFC reader when scanning?

Steps to Reproduce

  1. Scan an EU Passport NFC chip on IOS
  2. OnMessageRecieved doesn't fire

Basic Information

  • Version with issue: Latest

  • Last known good version: N/A

  • IDE:Version 8.6.5 (build 23)

  • Platform Target Frameworks:

    • iOS: 13.5
  • Nuget Packages:

  • Affected Devices: iPhone 11 iOS 13

iso 7816

Hi, NFC tag with type 7816 not recognized on iOS. I add these lines:
com.apple.developer.nfc.readersession.iso7816.select-identifiers
com.apple.developer.nfc.readersession.iso7816.select-identifiers
as written in setup.

  • Version with issue: 0.1.14
  • Platform Target Frameworks:
    • iOS: 13.3.1

Android not scanning

What happened:

I tried to add the nuget (v 0.1.11) to my optical scanner app to have RFID capabilities.

Couldn't make it scan - no events triggered.

I installed RFID Tools app from the store - worked fine on couple my credit cards (I don't want to scan credit cards - I just don't have any other RFID to test)

I downloaded source and ran your sample just in case - same result as my code - no events triggered..

Phone - Huawei P30 Lite, Android 9

this my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0a" package="com.tmd.imfxmobile" android:installLocation="auto">
	<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
	<application android:label="imfxMobile.Android" android:usesCleartextTraffic="true" android:icon="@mipmap/icon"></application>
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.CAMERA" />
	<uses-permission android:name="android.permission.FLASHLIGHT" />
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.NFC" />
	<uses-feature android:name="android.hardware.nfc" android:required="false" />
</manifest>

Android CrossNFC.Current.IsEnabled status not changing

Description

On the Xamarin Forms side the CrossNFC.Current.IsEnabled status not changing when i Enable/Disable the NFC on Android 10 phone.

Only when i subscribe the Plugin.NFC.CrossNFC.Current.OnNfcStatusChanged event!
Without the event subscription, the CrossNFC.Current.IsEnabled status, stays in the state it was in at the inicialization.

Steps to Reproduce

  1. Turn on NFC on phone.
  2. Start application.
  3. Disable NFC on phone
  4. CrossNFC.Current.IsEnabled is stuck on.

Expected Behavior

Update the internal CrossNFC.Current.IsEnabled state even when i not subscriben any status change event.

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
    Visual Studio 2019 v16.7.5
  • Platform Target Frameworks:
    • Android: Android 10.0 - API 29
  • Affected Devices:
    Ulefone Armor 7E

nuget version: v0.1.18

Add support for Mifare NFC tags

Description

The TagInfo does not contain data when scanning a MifareClassic NFC.

Steps to Reproduce

Scan a MifareClassic NFC by using the OnMessageReceived event

Expected Behavior

The Records property should contain data.

Actual Behavior

The Records property is null

Basic Information

  • Version with issue: 0.1.14
  • Last known good version: Unknown
  • IDE: Visual Studio 2019
  • Platform Target Frameworks: .NET Standard 2.0
    • iOS: n/a
    • Android: 9
    • UWP: n/a
  • Nuget Packages:
  • Affected Devices: Samsuns S9, OnePlus 3T, OnePlus 6T

Screenshots

afbeelding

Reproduction Link

n/a

NFC is not available/disabled on iPhone iOS 14

Hi folks,
I'm running some test in the NFC/RFID domain and found your package.
I managed to build your sample for iOS and loaded on my 2 iPhone (7 and X, both running iOS 14.x).
But I always get the message that the NFC is not available/disabled.
Do you have any advice or solution?
Is it an iOS compatibility reason?

Basic Information

  • Version with issue: 0.1.18
  • IDE: VS for Mac, Xamarin
  • Platform Target Frameworks:
    • iOS: 14.0.1
  • Affected Devices: iPhone 7 and X

OnMessageReceived duplicated

Description

When I read a nfc tag I get the result, the second time the event OnMessageReceived is called 2 times, 3 times on third and goes on.
Implemented according to Code description

Steps to Reproduce

  1. Read a tag, OnMessageReceived is called
  2. Read another Tag, OnMessageReceived is called 2 times.

Expected Behavior

OnMessageReceived should be called only once by read.

Actual Behavior

OnMessageReceived is called multiple times.

Basic Information

View:

public NFCSearch (NFCSearchViewModel vm = null)
		{
			InitializeComponent ();
            if (vm != null)
                this.BindingContext = vm;
            else
                this.BindingContext = new NFCSearchViewModel(Navigation);
            // Event raised when a ndef message is received.
            CrossNFC.Current.OnMessageReceived += ((NFCSearchViewModel)this.BindingContext).HandleNewTag;
            CrossNFC.Current.StartListening();

            CrossNFC.Current.OniOSReadingSessionCancelled += Current_OniOSReadingSessionCancelled;
            if (!CrossNFC.Current.IsAvailable)
            {
                App.Current.MainPage.DisplayAlert("Device not supported", "This device does not support NFC!", "Close");
            }
            if (!CrossNFC.Current.IsEnabled)
            {
                App.Current.MainPage.DisplayAlert("NFC disabled", "Please enable NFC on your device config!", "Close");
            }
        }

ViewModel:

public void HandleNewTag(ITagInfo tagInfo)
        {
            if (tagInfo.Records != null && !string.IsNullOrEmpty(tagInfo.Records[0].Message))
            {
                try
                {
                    string result = Encoding.GetEncoding("UTF-8").GetString(tagInfo.Records[0].Payload);
                    CrossNFC.Current.StopListening();
                    
                    ResultScan = result.Split('/').Last();
                    OpenEqu(ResultScan);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
  • Version with issue: 0.1.11
  • Last known good version: first test
  • IDE: VS Pro 2019
  • Platform Target Frameworks:
    • iOS: 13
    • Android: 9
  • Nuget Packages: 0.1.11
  • Affected Devices: Tested on iPhone 7 and Asus Zenfone 5z

No supported application for this NFC tag? [Pixel 3]

I'd like to get callback even when the application is minimized / closed (e.g. launch when a tag is detected).
According to the documentation (if I understand correctly) this should work for the provided sample. However, when I bring a simple RFID Tag (not full NFC compatible, I think MIFARE, but not exactly sure), I get the message "No supported application for this NFC tag" appear (when the application is closed). I'm using Pixel 3 device. When the application is running, it is able to detect the tag and report the serial number (ndef appears to be empty).

Am I missing something? How can I setup such that the app launches when a such tag is detected?

I should mention that I am only interested in the serial number of the tag, not in the (non existent ndef message)

Add support nfc tag id (serial number)

Description

There is no possibility to get nfc tag id (serial number). Sometimes the only id is needed.

Steps to Reproduce

  1. Subscribe to OnMessageReceived event
  2. Use NFC card with no data
  3. Event is handled

Expected Behavior

There is an information about NFC card id (serial number) in ITagInfo event argument

Actual Behavior

ITagInfo event argument is null

Additional information

Here is some code example how to change Android implementation (I'm not skilled enough in iOS yet).

//src/Plugin.NFC/Shared/ITagInfo.shared.cs
// TagInfo class should be changed too
	public interface ITagInfo
	{
		bool IsWritable { get; set; }
		bool IsEmpty { get; }
		NFCNdefRecord[] Records { get; set; }

		// new property
		string SerialNumber { get; set; }
	}
//src/Plugin.NFC/Android/NFC.android.cs

		ITagInfo GetTagInfo(Tag tag, NdefMessage ndefMessage = null)
		{
			if (tag == null)
				return null;
			
			// create nTag and get an id
			var nTag = new TagInfo();
			var nTagIdBytes = tag.GetId();
			var nTagId = nTagIdBytes == null ? 
						string.Empty : 
						string.Concat(nTagIdBytes.Select(b => b.ToString("X2")));
			nTag.SerialNumber = nTagId;


			var ndef = Ndef.Get(tag);

			if (ndef == null)
  				return nTag;
//				return null;

			if (ndefMessage == null)
				ndefMessage = ndef.CachedNdefMessage;

			nTag.IsWritable = ndef.IsWritable;
/*
			var nTag = new TagInfo()
			{
				IsWritable = ndef.IsWritable
			};
*/
			if (ndefMessage != null)
			{
				var records = ndefMessage.GetRecords();
				nTag.Records = GetRecords(records);
			}

			return nTag;
		}

Send class from phone to phone

Description

A Question

Is there no way to send data from 1 phone to another with nfc, android beam.

I would like to exchange data(maybe a json string) when 2 phones come close to each other

Thx for the advice

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Events raised for errors

Is there any event that is raised when a scan error for iOS occurs? For example if you get a "Stack Error" or a "Read error. Please try again" it shows the error on the iOS popup but I don't see any events that tells me there was an error.

Where is 0.1.17?

I notice the code has been updated to version 0.1.17, but the NuGet is still on 0.1.16?

Leave "NDEF not supported" evaluation to the user in iOS

Description

With iOS, when reading a tag without any data on it (like factory new) the plugin will throw the NFCErrorNotSupportedTag message ("Tag is not supported"), because there is no NDEF data and therefore NFCNdefStatus is "NotSupported". But what if I am not interested in the NDEF data and just want to read the serial number of the tag? What if I have tags and just want to identify them via this unique id. There is no chance to get this information. With "NFC Tools" it is also possible to read the serial number of tags without NDEF data.

Expected Behavior

Because the "TagInfo" class already has an "IsSupported" flag where the NDEF status is represented as I understand, I would expect to leave the decision to the plugin user whether to throw errors if NDEF is not supported. With that the user has the chance to read the serial number.

I would suggest to enhance the method DidDetectTags(NFCTagReaderSession session, INFCTag[] tags) in NFC.iOS.cs like this

ndefTag.QueryNdefStatus((status, capacity, error) =>
{
    if (error != null)
    {
        Invalidate(session, error.LocalizedDescription);
        return;
    }

    var isNdefSupported = status != NFCNdefStatus.NotSupported;

    var identifier = GetTagIdentifier(ndefTag);
    var nTag = new TagInfo(identifier, isNdefSupported)
    {
        IsWritable = status == NFCNdefStatus.ReadWrite,
        Capacity = Convert.ToInt32(capacity)
    };

    if (!isNdefSupported)
    {
        // if ndef is not supported do not read or write
        // let the plugin user decide if ndef support is needed
        OnMessageReceived?.Invoke(nTag);
        Invalidate(session);
        return;
    }

    if (_isWriting)
    {
    ...

Actual Behaviour

How it is right now:

ndefTag.QueryNdefStatus((status, capacity, error) =>
{
	if (error != null)
	{
		Invalidate(session, error.LocalizedDescription);
		return;
	}

	if (status == NFCNdefStatus.NotSupported)
	{
		Invalidate(session, Configuration.Messages.NFCErrorNotSupportedTag);
		return;
	}

	var identifier = GetTagIdentifier(ndefTag);
	var nTag = new TagInfo(identifier)
	{
		IsWritable = status == NFCNdefStatus.ReadWrite,
		Capacity = Convert.ToInt32(capacity)
	};

	if (_isWriting)
	{
        ...

Basic Information

  • Version with issue: 0.1.18
  • IDE: VS and Rider
  • Platform Target Frameworks:
    • iOS: 14.2

Issues Reading Mifare Classic 1k on iOS? Read this...

If you are having issues reading Mifare 1k Classic cards - the chances are the issue is not with this library, but with Apple's API.

On iOS 11, apple released the ability to READ NFC NDEF data only using the NfcNdefReaderSession API (https://developer.apple.com/documentation/corenfc/nfcndefreadersession)

A Mifare 1k Classic card will scan if there is a valid NDEF record on it. A blank card will not scan.

In iOS 11, it was not possible to obtain the CSN (serial number/identity) from NFC tags/card.

With iOS 13, along came the ability to write NDEF data AND read serial numbers. However, rather then adapting the NfcNdefReaderSession API, Apple created a NEW API called NfcTagReaderSession (https://developer.apple.com/documentation/corenfc/nfctagreadersession) and left the old NfcNdefReaderSession API untouched.

The new NfcTagReaderSession API in iOS 13 no longer supports Mifare Classic 1k cards period. No idea why - but if you look at Apple's Dev Forums multiple people have spotted the same thing.

So even if you have a Mifare Classic 1k card which reads fine with the old iOS 11 NfcNdefReaderSession API, that same card will not even scan with iOS 13's NfcTagReaderSession API.

If you need to read NDEF data off of a Mifare 1k Classic card, then you need to use version 0.1.11 of this library as it was written with the NfcNdefReaderSession API. Any subsequent versions moved over to the NfcTagReaderSession API

Unfortunately, even with iOS 13, it seems there is no way to read the serial number / CSN off of a Mifare Classic 1k card.

You must disable foreground dispatching while your activity is still resumed

Description

Had anyone seen this ?
"You must disable foreground dispatching while your activity is still resumed"

On Android - I need nfc scanning to listen for the tag only when button is pressed.
iOS - works ok for below code.

Steps to Reproduce

  1. Android app, when listening for tag one after another.
  2. below is the code from view model
	private async Task ScanAPointAsync()
        {
            IsBusy = true;
            try
            {
                string[] options = new string[] { "Scan Barcode" };
                if (CrossNFC.IsSupported && CrossNFC.Current.IsAvailable)
                {
                    options = new string[] { "Scan Barcode", "Read a Tag" };
                }

                var result = await page.DisplayActionSheet("Select", "Cancel", null, options);
                if (result == "Read a Tag")
                {
                    if (CrossNFC.Current.IsEnabled)
                    {
                        CrossNFC.Current.OnMessageReceived += Current_OnMessageReceived;
                        CrossNFC.Current.StartListening();
                    }
                    else
                    {
                        await page.DisplayAlert("Enable NFC", "Please enable NFC on your phone.", "OK");
                    }
                }
            }
            catch (Exception)
            {
                await page.DisplayAlert("Error", "Something went wrong, Please try again.", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }

	private async void Current_OnMessageReceived(ITagInfo tagInfo)
        {
            if (tagInfo != null)
            {
		string serialNumber = tagInfo.SerialNumber;
		
		// do something more here

                CrossNFC.Current.OnMessageReceived -= Current_OnMessageReceived;
                CrossNFC.Current.StopListening();
            }
        }

Expected Behavior

shouldnt crash

Actual Behavior

App Crashes with
"You must disable foreground dispatching while your activity is still resumed"

Basic Information

  • Version with issue: 0.1.16
  • Last known good version: NA
  • IDE: Visual Studio
  • Platform Target Frameworks:
    • Android: 10.0

Opening app with IntentFilter does not work on Android

Description

I want my app to open when one of my tags is scanned. I can't get it to work on Android.

Steps to Reproduce

  1. I write a tag with the following NFCNdefRecord:
var record = new NFCNdefRecord {
    TypeFormat = NFCNdefTypeFormat.WellKnown,
    MimeType = MIME_TYPE,
    Payload = NFCUtils.EncodeToByteArray(_writePayload)
};
  1. I add the IntenFilter in MainActivity:
[Activity(Label = "SoundMem", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
[IntentFilter(new[] { NfcAdapter.ActionNdefDiscovered }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = Services.Nfc.NfcService.MIME_TYPE)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  1. I start the app via debugger once, close it.
  2. I scan the previously written tag.

Expected Behavior

My app opens.

Actual Behavior

Some default android nfc service opens, showing me the writePayload.

Basic Information

  • IDE: VS2019 Preview
  • Platform Target Frameworks:
    • Android: 10.0 - API 29
  • Nuget Packages:
  • Newtonsoft.Json (12.0.3)

How can I write an NFC tag that an RFID reader understands?

Description

I have the RFID reader RD200-M1-G, which is compatible with: MIFARE 1K S50, 4K S70 4/7-byte UID and MIFARE Ultralight.
I use the sample trying to write an NFC tag that the reader can understand (hex):

image

But it doesn't read the code I want, instead random codes come out:

image

It's possible? Thank you.

Android sample - Write functionality needs fixing

Description

Awesome work Franck! I was able to build it on iOS & Android and all the sample functionality worked great on iOS, however, the write functionality in the Android sample needs few fixes. We are able to read data all the time, but the Write and Clear buttons only work on App launch. I suspect it's because in your Main.xaml.cs you don't run CrossNFC.Current.StartListening(); when the other buttons are tapped, only when the "Read Tag" button is tapped and in OnAppearing()

Steps to Reproduce

  1. Using a supported NFC tag and an Android device that has NFC enabled, build the app and run it.
  2. Tap the read tag button and scan the NFC tag to see that the tag has some URI inside it.
  3. Then tap the "Write Tag(text)" button, and scan the NFC tag. Instead of saying "Writing tag successfully", the phone uses the default NFC listener to open the URI using a browser, because evidently it doesn't register the Listener.

Note: The same behavior is reflected when you tap the "Write Tag(uri)", "Write Tag(custom)" and "Clear Tag" buttons instead instead of step 3

Expected Behavior

  • The phone should display "Writing Tag Successfully" and actually write the text values into the tag

Actual Behavior

  • The phone instead opens a dialog box asking: "Complete action using Chrome, Just Once, Always" as it would when brought near the NFC tag before the app was installed.

Basic Information

  • Version with issue:
  • Last known good version: Master branch of this repository
  • IDE: Visual Studio for Mac 2019
  • Platform Target Frameworks:
    • iOS: Latest iOS running on iPhone 8 works
    • Android: Android 10 running on the Pixel
    • UWP: Didn't test
  • Nuget Packages: The sample doesn't use Nuget, it uses the Libraries directly
  • Affected Devices: Pixel

Screenshots

This is the screen that appears after you tap on the Write Button:
Screenshot_20200513-215811
This is the screen that appears after you bring your phone close to the NFC tag:
Screenshot_20200513-215805

Reproduction Link

N/A

Suggested Fix

Based on my findings I created a PR #30 with a Fix that I tested

The "Identifier" Property in the ITagInfo Object is Reversed for iOS

Description

When scanning an NFC tag, the "Identifier" property in the ITagInfo object is reversed for iOS, and subsequently shows a different SerialNumber property for the same tag.

The "NFC Tools" app on both Android and iOS show the same serial number when scanning a tag. Android using Plugin.NFC also matches this serial number. It's only when I use Plugin.NFC on iOS that I'm seeing the reversal.

Steps to Reproduce

  1. Set a breakpoint on the "Current_OnMessageReceived" method.
  2. Use "Quick Watch" in Visual Studio to analyze the ITagInfo parameter object.
  3. Compare values between iOS and Android.

Expected Behavior

I expect to receive the same serial number on iOS and Android when scanning a tag. I use the serial number for a database lookup request, so they need to be the same across platforms.

Basic Information

  • Version with issue: v0.1.18
  • Platform Target Frameworks:
    • iOS: 14.1
    • Android: 10
  • Affected Devices: iPhone SE (2nd Generation) and Samsung Galaxy S9

Screenshots

Android
image

iOS
image

Make Read Only

Is there an option to make the tag read only after it has been written?

The executable was signed with invalid entitlements

Tried deploying the sample you have here to an iPhone and I get (The executable was signed with invalid entitlements).

I'm almost positive it has nothing to do with your code, its a config issue but can't seem to get past it.

I've gone to the point of just deploying a "fresh" Xamarin Forms app with nothing more changed than selecting NFC in the entitlements.plist and I get the same error.

Thanks in advance
-Todd

  • IDE: VS2019
  • Platform Target Frameworks:
    • iOS: iOS 13.3
    • Android: WORKS GREAT!
    • UWP:
  • Nuget Packages:
  • Affected Devices:

reading different payload than written

Hi

I'm using NFC for years on my desktop and windows phone. I developed my libraries to handle the content from the payload written on the desktop app and reading same content in the windows phone app.
Now I want to redevelop the app on Android.
To handle the NFC I'm using this library BUT I get a totally different content in the payload.
If I write the content in the desktop app and read it in Xamarin.Forms the payload byte array look not even similar...

the base64 encoded string on desktop, which is written/read as payload, starts like
"KjAANAAgAEMAOAAgADAAOAAgADkAQQAgADkAOAAgADMAQwAg...."

and reading the same NFC card the string I receive from Plugin.NFC as payload starts like
"AAEMV2luZG93c1Bob25lJns4YzFjMTE1Yy1kNmNkLTRhM2QtYWZkYS02YjMyZGNlMDhlND..."

As environment I use VS2019 preview Version 16.5.0 Preview 2.
and Plugin.NFC comes in via nuget as 0.1.14

Any help is appreciated
Achim

Credit Card

I want to create payment system in my application. Payment system will be use NFC credit card. I am scan credit card and ı receive not supported tag. How ı can handle this thing ?

Doesn't work on Android

Description

I installed the sample project on two andorid phones (Samsung s10+ and Note 4). It keeps giving the exact same information (as in the attachment) no matter what i try to "write" to either phone.

Steps to Reproduce

  1. Install on each phone
  2. Attempt to write to either phone
  3. Attempt to read from either phone.

Expected Behavior

  1. Tags should be written successfully.
  2. Tags should be read successfully with the correct message written on the tag.

Actual Behavior

When writing or reading, sometimes i get either:

  1. Tag does not support NDEF format.
  2. No tag.
  3. Or the same message as attached

Basic Information

  • Version with issue:
    Latest version.

  • Last known good version:

  • IDE:
    Vs for mac.

  • Platform Target Frameworks:

    • iOS: (not attempted yet)

    • Android: android 6 and 10

  • Nuget Packages:

  • Affected Devices:
    Samsung galaxy s10+
    Samsung note 4

Screenshots

Screenshot_20200907-114747

Reproduction Link

[iOS] NFC Tag not reading on iOS unless I have a message on the tag

Description

Basically the title. I can't read a NFC on iOS unless it has a message on it. For the purposes of my app, I'm only really wanting to get the "SerialNumber" from the scan and thus, leave the tag empty.

I've got the code working as intended on Android with both a empty tag and tag with a "test" message on it working.

On iOS, if I scan the tag with the "test" message it works but I get "stack error" or "read error please try again" on an empty tag. I'm using OnMessageReceived which I thought might be the issue due to its naming but as I said, on Android with an empty tag, I get the intended output.

Expected Behaviour

Scan the NFC tag and the corresponding OnMessageReceived method would run, giving me the tag's SerialNumber (does so in Android)

Actual Behaviour

None of the events (OnMessageReceived, even tried "OnTagDiscovered") fire and I'm left with either "stack error" or "read error please try again" errors in the GUI.

Basic Information

  • Version with issue: 0.1.16
  • Last known good version: N/A
  • IDE:
  • Platform Target Frameworks:
    • iOS: 13.5.1
    • Android: 7.0
      Nuget Packages:
  • Affected Devices:
    Tested on a HUAWEI P10 Plus
    Tested on an iphone 7

Screenshots

https://i.imgur.com/fl0mYva.png - Tag info in case that's needed

Could be missing something obvious so apologies if that's the case and thanks for any help you's can provide.

Authenticate NFC before writing

Is there anyway to authenticate the NFC card before writing to the NFC tag? What happen is that the NFC tag I am writing to is password protected.
Help needed, thank you!

IOS cancel button cause app crash

On newest version (0.11.1) when scan session appear, click on cancel button cause app crash. I try debugging and get Null Exception in function DidInvalidate.

Full stacktrace:
at Plugin.NFC.NFCImplementation.DidInvalidate (CoreNFC.NFCNdefReaderSession session, Foundation.NSError error) [0x0008f] in :0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.16.1.17/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.16.1.17/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at AutoStep.iOS.Application.Main (System.String[] args) [0x00001] in /Users/Yuudachi/TuanNQ8/xamarin/TFS5/AutoStep/src/AutoStep/Source/AutoStep.Mobile/AutoStep/AutoStep.iOS/Main.cs:18

Please add ISO15693 tags

Description

Please add ISO15603 tags support - to iOS

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

[iOS] Support for writing NFC Tags

Apple expands NFC on iPhone in iOS 13:

  • Support for writing NDEF messages.
  • Support for reading NFC Tag in background for some devices.
  • Access to the NFC chip UID.

Get ITagInfo of Launch Tag

Thank you for the great plugin. Easy to use and works very well.
I made an app which is launched on scanning a tag.
The app gets startet as it should be.
But how can I get the Tag Information (I am interrested in the Serialnumber) for this Launch Tag?

I am using this Plugin in my Visual Studio 2019 solution with version 0.1.19 of your plugin.

[ BUG ] Java.Lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed

Description

When scanning an NFC tag on Android 10, I get the following exception:

Java.Lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <9324da45a6654f83baffa7c2854d836a>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00014] in <9324da45a6654f83baffa7c2854d836a>:0 
  at Android.Nfc.NfcAdapter.EnableForegroundDispatch (Android.App.Activity activity, Android.App.PendingIntent intent, Android.Content.IntentFilter[] filters, System.String[][] techLists) [0x0008e] in <eaa205f580954a64824b74a79fa87c62>:0 
  at Plugin.NFC.NFCImplementation.StartListening () [0x0008f] in <aa6103da0da343a6ad2d3f737fa2443d>:0 
  at {Private}.Scanner.<StartNFC>b__53_0 () [0x00030] in {Private}.Scanner.cs:305 
  at Xamarin.Essentials.MainThread.BeginInvokeOnMainThread (System.Action action) [0x00007] in d:\a\1\s\Xamarin.Essentials\MainThread\MainThread.shared.cs:16 
  at {Private}.Scanner.StartNFC () [0x00001] in {Private}.Scanner.cs:297 
  at {Private}.Scanner.AfterNFC (System.Threading.CancellationToken token) [0x0010e] in {Private}.Scanner.cs:274 
  at {Private}.LoadingAsyncTask (System.Func`2[T,TResult] func, System.String title, System.String cancel, Acr.UserDialogs.MaskType mask) [0x000d3] in {Private}:88 
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
	at android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1787)
	at crc64d79a34a3c547b7ed.MainActivity.n_onNewIntent(Native Method)
	at crc64d79a34a3c547b7ed.MainActivity.onNewIntent(MainActivity.java:55)
	at android.app.Activity.performNewIntent(Activity.java:7971)
	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1407)
	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1420)
	at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3779)
	at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3791)
	at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:53)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2229)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loop(Looper.java:237)
	at android.app.ActivityThread.main(ActivityThread.java:8034)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

For a fix, see StackOverFlow Post

See Android Documentation for more details on enableForegroundDispatch

Steps to Reproduce

  1. scan tag on Android 10 device
  2. boom

Expected Behavior

Scan the tag. Started getting this exception and now I can't get it to work again.

Actual Behavior

The exception is thrown.

Basic Information

  • Version with issue: Plugin.NFC 0.1.16
  • Last known good version: Unknown
  • IDE: Visual Studio 2019 v16.6.3
  • Platform Target Frameworks:
    • iOS: Untested
    • Android: 10.0
    • UWP: Untested
  • Nuget Packages: Xamarin.Forms v4.7.0.1080
  • Affected Devices:

Screenshots

Reproduction Link

Wrong behavior with Navigation

I use navigation in my xamarin.forms app and "OnAppearing" calling again when tag is detected by device. And I get 'Tag is missing' when try to write tag. Everything will be ok in singlepage application.

To reproduce error you can change App.xaml.cs in your sample:
MainPage = new NavigationPage(new MainPage());
and try to write tag

IOS 13.6 IPhone 11 Pro Max wont scan ISO 14443-4 NXP MiFare Plus

Description

Hi Trying to use this framework but not working for: IOS 13.6 IPhone 11 Pro Max, wont scan IOS 14443-4 NXP MiFare Plus
-Works fine on Andriod,
-It wont scan using "NFCTagReaderSession"
-it will read using "NFCNdefReaderSession", tried another stand along project

Any ideas? trying to use "NFCTagReaderSession", to write to tag.

Steps to Reproduce

  1. Build/run app on IOS (13.0+)13.6 IPhone 11 Pro Max
  2. Click read tag
  3. Popup shows "Please hold your phone near a NFC tag"
  4. Hover phone on top of tag, but never reads it.

Expected Behavior

Should read a the tag

Actual Behavior

Never reads it.

Basic Information

Using NFC Tools App to scan the same tag says its a = IOS 14443-4 NXP MiFare Plus tag

  • Version with issue:
  • Last known good version:
  • IDE: Visual Studio for Mac
  • Platform Target Frameworks: IOS13, IOS13.6
    • iOS: IOS13, IOS13.6 (builds and runs but wont scan tag)
    • Android: 9, works fine
    • UWP: N/A
  • Nuget Packages: no changes exactly as in your solution
  • Affected Devices: IPhone 11 Pro Max

Screenshots

Reproduction Link

Enable setting LanguageCode for TextRecords

Description

Steps to Reproduce

  1. Use the sample to write a TextRecord on Android

Expected Behavior

Have a possibility to set the Language code when creating a TextRecord

Actual Behavior

Uses Locale.Default.ToLanguageTag() (NSLocale.CurrentLocale on IOS) which obtains the current (set on the device) language.

I want to create Tags with specific (different) LanguageCodes on a device.

A simple way would be that you make the methods GetiOSPayload / GetAndroidNdefRecord virtual so it would be easy to enhance the record creation.

Writing same tag just read

Hi

I can read tags one by one without any problems.
Now I need to write the changed record on the tag at once.
Scenario: one comes with a card (tag) and holds it on the phone. The tag is read, data is checked. card is ok --> write current date (within the data) back to the card.
BUT the card cannot be moved around. this must be done in one step

Can someone guide me, how this is done? I can read, but when I try to write instantly, the card (the data on the card) is unreadable...

thanks in advane
Achim

Issue with NFC on Android

Description

I cant seem to make it work, I've followed the instructions, but nothing happens when CrossNFC.Current.StartListening(); is called. On iOS if work like a charm. I have added these line inside -tag:

I have also init it in MainActivity.cs in onCreate()

My manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="41" android:versionName="1.41" package="se.edgeteq.loyiz" android:installLocation="auto"> <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="29" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.FLASHLIGHT" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- Dessa rader används för NFC --> <uses-permission android:name="android.permission.NFC" /> <uses-feature android:name="android.hardware.nfc" android:required="false" /> <!-- Dessa rader används för Beacon --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- Dessa rader används för Beacon --> <permission android:name="se.edgeteq.loyiz.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <application android:label="Mingo" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="true"> <uses-library android:name="org.apache.http.legacy" android:required="false" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="[HIDDEN]" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data> </provider> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" /> <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/facebook_app_name" /> <activity android:name="com.facebook.CustomTabActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/fb_login_protocol_scheme" /> </intent-filter> </activity> </application> </manifest>

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue: 0.1.15
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android: 10.0
    • UWP:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Android scan NFC all the time.

Description

I'm Junior Developer in Thailand. I want to scan NFC all the time without clicked button to read.
Can I make it scan all the time ? And I want to know how to make it.

Steps to Reproduce

  1. Open Forms
  2. Scan NFC
  3. Exception
    ** I try add code "CrossNFC.Current.StartListening();" on many location but it's cannot StartListening again.

Expected Behavior

I want can scan NFC all the time on the Forms. I think, it's should have "OnListeningCompleted" or you have idea to can Listening all the time. Can you tell me please!!!

Actual Behavior

Basic Information

  • Version with issue: 0.1.16
  • Last known good version: (0.1.16 first version for me)
  • IDE: Microsoft Visual Studio 2017 (Xamarin-Forms)
  • Platform Target Frameworks:
    • iOS: -
    • Android: Android 9.0-Pie
    • UWP: -
  • Nuget Packages: Plugin.NFC 0.1.16
  • Affected Devices: Xiaomi mi 8 pro

Screenshots

Reproduction Link

Supporting raw tag (not ndef} on iOS

Description

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Need help with App Lifecycle to auto-run NFC reader

Description

I'm fumbling thru a app that uses your sample code with a WebView control to show C# WebForm pages from NFC URLs. I've modified the example code to work with the button code at the end of issue #33 but I'm lost on how to get NFC to start and stop from App.OnStart(), App.OnSleep() and App.OnResume(). I have no experience with Xamarin or mobile app development.

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Can only identify tags once with the sample app on pixel 3

Everything seems to be working fine initially. I launched the sample app. Placed a tag nearby and it is recognized (I can get the serial number). However, any attempt to scan another tag afterwards gives me the error "No supported application for this NFC Tag". When I click "Read Tag" again, somehow this resets this behavior and I can read another tag. But then it goes back to "No supported application for this NFC Tag".
I suspect somehow the activity hangs or doesn't return the correct value back to Android to report that it successfully handled the intent?

Tag Is Missing Exception

Description

I am getting an exception when trying to write a tag

What is weird is that the system actually writes the tag after throwing the exception, also not happening on the DEV phone.

The exception is that the 'Tag is missing'

Here is the stack trace I am getting:
Plugin.NFC
NFCImplementation.WriteOrClearMessage (Plugin.NFC.ITagInfo tagInfo, System.Boolean clearMessage, System.Boolean makeReadOnly)
Plugin.NFC
NFCImplementation.PublishMessage (Plugin.NFC.ITagInfo tagInfo, System.Boolean makeReadOnly)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.