1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

nfc updates

This commit is contained in:
Kyle Spearrin 2018-05-24 12:49:22 -04:00
parent 740a18dbc0
commit e7bc9ed5ba
2 changed files with 23 additions and 11 deletions

View File

@ -28,6 +28,7 @@ namespace Bit.iOS
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{ {
private GaiCompletionHandler _dispatchHandler = null; private GaiCompletionHandler _dispatchHandler = null;
private NFCNdefReaderSession _nfcSession = null;
private ILockService _lockService; private ILockService _lockService;
private IDeviceInfoService _deviceInfoService; private IDeviceInfoService _deviceInfoService;
private iOSPushNotificationHandler _pushHandler = null; private iOSPushNotificationHandler _pushHandler = null;
@ -117,16 +118,25 @@ namespace Bit.iOS
return; return;
} }
var del = new NFCReaderDelegate((success, message) => if(listen)
{ {
Debug.WriteLine((success ? "SUCCESS! " : "ERROR! ") + message); var del = new NFCReaderDelegate((success, message) =>
if(success)
{ {
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message); Debug.WriteLine((success ? "SUCCESS! " : "ERROR! ") + message);
} if(success)
}); {
var session = new NFCNdefReaderSession(del, null, true); MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
session.BeginSession(); }
});
_nfcSession = new NFCNdefReaderSession(del, null, true);
_nfcSession.BeginSession();
}
else
{
_nfcSession?.InvalidateSession();
_nfcSession = null;
}
}); });
UIApplication.SharedApplication.StatusBarHidden = false; UIApplication.SharedApplication.StatusBarHidden = false;

View File

@ -35,10 +35,12 @@ namespace Bit.iOS
foreach(var result in results) foreach(var result in results)
{ {
Debug.WriteLine("READ TAG: " + result); Debug.WriteLine("READ TAG: " + result);
if(_otpPattern.IsMatch(result)) var matches = _otpPattern.Matches(result);
if(matches.Count > 0 && matches[0].Groups.Count > 1)
{ {
Debug.WriteLine("TAG IS MATCH: " + result); var otp = matches[0].Groups[1].ToString();
_callback.Invoke(true, result); Debug.WriteLine("TAG IS MATCH: " + otp);
_callback.Invoke(true, otp);
return; return;
} }
} }