/// <summary> /// Event raised when an error happened during detection /// </summary> /// <param name="session">iOS <see cref="NFCTagReaderSession"/></param> /// <param name="error">iOS <see cref="NSError"/></param> public override void DidInvalidate(NFCNdefReaderSession session, NSError error) { var readerError = (NFCReaderError)(long)error.Code; if (readerError != NFCReaderError.ReaderSessionInvalidationErrorFirstNDEFTagRead && readerError != NFCReaderError.ReaderSessionInvalidationErrorUserCanceled) { var alertController = UIAlertController.Create("Session Invalidated", error.LocalizedDescription, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); DispatchQueue.MainQueue.DispatchAsync(() => { GetCurrentController().PresentViewController(alertController, true, null); }); } else if (readerError == NFCReaderError.ReaderSessionInvalidationErrorUserCanceled) { OniOSReadingSessionCancelled?.Invoke(null, EventArgs.Empty); } }
/// <summary> /// Event raised when an error happened during detection /// </summary> /// <param name="session">iOS <see cref="NFCTagReaderSession"/></param> /// <param name="error">iOS <see cref="NSError"/></param> public override void DidInvalidate(NFCTagReaderSession session, NSError error) { var readerError = (NFCReaderError)(long)error.Code; if (readerError != NFCReaderError.ReaderSessionInvalidationErrorFirstNDEFTagRead && readerError != NFCReaderError.ReaderSessionInvalidationErrorUserCanceled) { var alertController = UIAlertController.Create(Configuration.Messages.NFCSessionInvalidated, error.LocalizedDescription.ToLower().Equals(SessionTimeoutMessage) ? Configuration.Messages.NFCSessionTimeout : error.LocalizedDescription, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create(Configuration.Messages.NFCSessionInvalidatedButton, UIAlertActionStyle.Default, null)); DispatchQueue.MainQueue.DispatchAsync(() => { GetCurrentController().PresentViewController(alertController, true, null); }); } else if (readerError == NFCReaderError.ReaderSessionInvalidationErrorUserCanceled && !_customInvalidation) { OniOSReadingSessionCancelled?.Invoke(null, EventArgs.Empty); } }