/// <summary> /// Starts scanning for nfc tags. /// </summary> /// <param name="nfc"><see cref="ICrossNearFieldCommunication"/> to use.</param> public async static void GloballyStartScanning(ICrossNearFieldCommunication nfc) { _nfc = nfc; _nfc.Association = Association; _nfc.Initialize(); await _nfc.StartListeningAsync(); }
/// <summary> /// Attempts to stop scanning for nfc tags. /// </summary> public async static void TryGloballyStopScanning() { if (await _nfc?.TryStopListeningAsync()) { _nfc = null; } else { Console.WriteLine("Unable to stop scanning, check console for error - XNFC"); } }
/// <summary> /// Attempts to start scanning for nfc tags. /// </summary> /// <param name="nfc"><see cref="ICrossNearFieldCommunication"/> to use.</param> public async static void TryGloballyStartScanning(ICrossNearFieldCommunication nfc) { try { _nfc = nfc; _nfc.Association = Association; _nfc.Initialize(); } catch (Exception e) { Console.WriteLine("Unable to start scanning - XNFC"); Console.WriteLine($"Error: {e}"); return; } if (!await _nfc?.TryStartListeningAsync()) { Console.WriteLine("Unable to start scanning, check console for error - XNFC"); } }
public MainPage() { _xnfc = XNFC.GetApi(); _xnfc.TagDetected += XnfcOnTagDetected; InitializeComponent(); }
/// <summary> /// Stops scanning for nfc tags. /// </summary> public async static void GloballyStopScanning() { await _nfc?.StopListeningAsync(); _nfc = null; }