mirror of
https://github.com/bitwarden/android.git
synced 2025-01-12 11:17:30 +03:00
move nfc delegate to member of appdelegate class
This commit is contained in:
parent
d3646e10a5
commit
f90c407fb6
1 changed files with 17 additions and 19 deletions
|
@ -33,6 +33,7 @@ namespace Bit.iOS
|
||||||
private ILockService _lockService;
|
private ILockService _lockService;
|
||||||
private IDeviceInfoService _deviceInfoService;
|
private IDeviceInfoService _deviceInfoService;
|
||||||
private iOSPushNotificationHandler _pushHandler = null;
|
private iOSPushNotificationHandler _pushHandler = null;
|
||||||
|
private NFCReaderDelegate _nfcDelegate = null;
|
||||||
|
|
||||||
public ISettings Settings { get; set; }
|
public ISettings Settings { get; set; }
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ namespace Bit.iOS
|
||||||
_lockService = Resolver.Resolve<ILockService>();
|
_lockService = Resolver.Resolve<ILockService>();
|
||||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||||
_pushHandler = new iOSPushNotificationHandler(Resolver.Resolve<IPushNotificationListener>());
|
_pushHandler = new iOSPushNotificationHandler(Resolver.Resolve<IPushNotificationListener>());
|
||||||
|
_nfcDelegate = new NFCReaderDelegate((success, message) => ProcessYubikey(success, message));
|
||||||
var appIdService = Resolver.Resolve<IAppIdService>();
|
var appIdService = Resolver.Resolve<IAppIdService>();
|
||||||
|
|
||||||
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
|
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
|
||||||
|
@ -119,30 +121,15 @@ namespace Bit.iOS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nfcSession?.InvalidateSession();
|
||||||
|
_nfcSession?.Dispose();
|
||||||
|
_nfcSession = null;
|
||||||
if(listen)
|
if(listen)
|
||||||
{
|
{
|
||||||
_nfcSession?.InvalidateSession();
|
_nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true);
|
||||||
_nfcSession?.Dispose();
|
|
||||||
_nfcSession = null;
|
|
||||||
_nfcSession = new NFCNdefReaderSession(new NFCReaderDelegate((success, message) =>
|
|
||||||
{
|
|
||||||
if(success)
|
|
||||||
{
|
|
||||||
Device.BeginInvokeOnMainThread(() =>
|
|
||||||
{
|
|
||||||
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}), null, true);
|
|
||||||
_nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
|
_nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
|
||||||
_nfcSession.BeginSession();
|
_nfcSession.BeginSession();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_nfcSession?.InvalidateSession();
|
|
||||||
_nfcSession?.Dispose();
|
|
||||||
_nfcSession = null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
UIApplication.SharedApplication.StatusBarHidden = false;
|
UIApplication.SharedApplication.StatusBarHidden = false;
|
||||||
|
@ -362,5 +349,16 @@ namespace Bit.iOS
|
||||||
|
|
||||||
Gai.SharedInstance.Dispatch(_dispatchHandler);
|
Gai.SharedInstance.Dispatch(_dispatchHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProcessYubikey(bool success, string message)
|
||||||
|
{
|
||||||
|
if(success)
|
||||||
|
{
|
||||||
|
Device.BeginInvokeOnMainThread(() =>
|
||||||
|
{
|
||||||
|
MessagingCenter.Send(Xamarin.Forms.Application.Current, "GotYubiKeyOTP", message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue