franckbour / plugin.nfc Goto Github PK
View Code? Open in Web Editor NEWA Cross-Platform NFC (Near Field Communication) plugin to easily read and write NFC tags in your application.
License: MIT License
A Cross-Platform NFC (Near Field Communication) plugin to easily read and write NFC tags in your application.
License: MIT License
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.
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!!!
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
Have a possibility to set the Language code when creating a TextRecord
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.
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
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 ?
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.
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.
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();
}
}
shouldnt crash
App Crashes with
"You must disable foreground dispatching while your activity is still resumed"
The tag cannot read after press home button
Card should be read at step 5.
The app does not has response at step 5.
I used this as reference
https://www.uuu.com.tw/Public/content/article/20/20200427.htm
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.
Just wondering if it is possible to set/remove password? If it is possible could you give me a hand and guide me how to use it?
Thank you!
Feature request to be able to access the capacity/max size of a 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.
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!
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?
Version with issue: Latest
Last known good version: N/A
IDE:Version 8.6.5 (build 23)
Platform Target Frameworks:
Nuget Packages:
Affected Devices: iPhone 11 iOS 13
Hello, I want to know how I change the default NFCDialogAlertMessage?
Does this plugin, by any chance, can help me with card emulation?
There is no possibility to get nfc tag id (serial number). Sometimes the only id is needed.
There is an information about NFC card id (serial number) in ITagInfo event argument
ITagInfo event argument is null
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;
}
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.
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
I notice the code has been updated to version 0.1.17, but the NuGet is still on 0.1.16?
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.
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.
Apple expands NFC on iPhone in iOS 13:
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?
The TagInfo does not contain data when scanning a MifareClassic NFC.
Scan a MifareClassic NFC by using the OnMessageReceived event
The Records property should contain data.
The Records property is null
n/a
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>
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.
Should read a the tag
Never reads it.
Using NFC Tools App to scan the same tag says its a = IOS 14443-4 NXP MiFare Plus tag
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.
Update the internal CrossNFC.Current.IsEnabled state even when i not subscriben any status change event.
nuget version: v0.1.18
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):
But it doesn't read the code I want, instead random codes come out:
It's possible? Thank you.
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?
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.
Scan the NFC tag and the corresponding OnMessageReceived method would run, giving me the tag's SerialNumber (does so in Android)
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.
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.
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
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.
I want my app to open when one of my tags is scanned. I can't get it to work on Android.
var record = new NFCNdefRecord {
TypeFormat = NFCNdefTypeFormat.WellKnown,
MimeType = MIME_TYPE,
Payload = NFCUtils.EncodeToByteArray(_writePayload)
};
[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
My app opens.
Some default android nfc service opens, showing me the writePayload.
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.
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)
{
...
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)
{
...
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)
dotnet, xamarin are the first ones to come to mind.
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()
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
This is the screen that appears after you tap on the Write Button:
This is the screen that appears after you bring your phone close to the NFC tag:
N/A
Based on my findings I created a PR #30 with a Fix that I tested
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
Scan the tag. Started getting this exception and now I can't get it to work again.
The exception is thrown.
<>
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)
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.
When writing or reading, sometimes i get either:
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
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
Is there an option to make the tag read only after it has been written?
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
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
OnMessageReceived should be called only once by read.
OnMessageReceived is called multiple times.
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;
}
}
}
Please add ISO15603 tags support - to iOS
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>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.