No I am using TagReaderSession only but its failing silently Did detect is not getting called
for the tag mentioned above in screenshot
this is how i am intiating the NFC Session is this correct way or anything is Missed
public class NfcServiceIos : INfcServiceIos
{
private SessionDelegate _currentDelegate;
private bool _sessionActive = false;
private NFCTagReaderSession _currentSession;
public async Task SendAsync(byte[] bytes)
{
var isNfcAvailable = UIDevice.CurrentDevice.CheckSystemVersion(11, 0);
if (isNfcAvailable && NFCTagReaderSession.ReadingAvailable)
{
if (_sessionActive)
{
await Application.Current.MainPage.DisplayAlert("Error", "NFC session is still active. Please wait.", "Ok");
return;
}
_sessionActive = true;
_currentDelegate = new SessionDelegate(bytes, OnSessionInvalidated);
// All CoreNFC session code must be on the main thread!
await Microsoft.Maui.ApplicationModel.MainThread.InvokeOnMainThreadAsync(() =>
{
// create NFCTagReaderSession instead of NFCNdefReaderSession
_currentSession = new NFCTagReaderSession(NFCPollingOption.Iso14443,_currentDelegate, null);
_currentSession.AlertMessage = "Please hold your device near the NFC tag";
_currentSession.BeginSession();
});
var status = await _currentDelegate.WasDataTransmitted.Task;
_currentSession = null;
_currentDelegate = null;
if (status != NfcTransmissionStatus.Success)
{
await Application.Current.MainPage.DisplayAlert("Error", "Suitable error message", "Ok");
}
}
else
{
await Application.Current.MainPage.DisplayAlert("Error", "Read is not supported by this tag", "Ok");
}
}
private void OnSessionInvalidated()
{
Application.Current.MainPage.DisplayAlert("Error", "Read Sesssion Invalidated Silently ", "Ok");
_sessionActive = false;
}