diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index b8266c157..06224b3db 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -1590,6 +1590,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Hold your Yubikey near the top of the device.. + /// + public static string HoldYubikeyNearTop { + get { + return ResourceManager.GetString("HoldYubikeyNearTop", resourceCulture); + } + } + /// /// Looks up a localized string similar to Host. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index c2631f29c..d55543884 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1293,4 +1293,7 @@ Organization An entity of multiple related people (ex. a team or business organization). + + Hold your Yubikey near the top of the device. + \ No newline at end of file diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index c75466c85..133f54722 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -21,6 +21,7 @@ using FFImageLoading.Forms.Touch; using SimpleInjector; using XLabs.Ioc.SimpleInjectorContainer; using CoreNFC; +using Bit.App.Resources; namespace Bit.iOS { @@ -120,21 +121,26 @@ namespace Bit.iOS if(listen) { - var del = new NFCReaderDelegate((success, message) => + _nfcSession?.InvalidateSession(); + _nfcSession?.Dispose(); + _nfcSession = null; + _nfcSession = new NFCNdefReaderSession(new NFCReaderDelegate((success, message) => { - Debug.WriteLine((success ? "SUCCESS! " : "ERROR! ") + message); if(success) { - MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message); + Device.BeginInvokeOnMainThread(() => + { + MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message); + }); } - }); - - _nfcSession = new NFCNdefReaderSession(del, null, true); + }), null, true); + _nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop; _nfcSession.BeginSession(); } else { _nfcSession?.InvalidateSession(); + _nfcSession?.Dispose(); _nfcSession = null; } }); diff --git a/src/iOS/NFCReaderDelegate.cs b/src/iOS/NFCReaderDelegate.cs index eac4e4296..2b1891255 100644 --- a/src/iOS/NFCReaderDelegate.cs +++ b/src/iOS/NFCReaderDelegate.cs @@ -34,12 +34,10 @@ namespace Bit.iOS foreach(var result in results) { - Debug.WriteLine("READ TAG: " + result); var matches = _otpPattern.Matches(result); if(matches.Count > 0 && matches[0].Groups.Count > 1) { var otp = matches[0].Groups[1].ToString(); - Debug.WriteLine("TAG IS MATCH: " + otp); _callback.Invoke(true, otp); return; }