bitwarden-android/src/iOS.Core/Services/DeviceInfoService.cs

50 lines
1.4 KiB
C#
Raw Normal View History

using Bit.App.Abstractions;
2017-11-29 23:47:43 +03:00
using Foundation;
using LocalAuthentication;
using UIKit;
namespace Bit.iOS.Core.Services
{
public class DeviceInfoService : IDeviceInfoService
{
public string Model => UIDevice.CurrentDevice.Model;
public int Version
{
get
{
int version;
var versionParts = UIDevice.CurrentDevice.SystemVersion.Split('.');
if(versionParts.Length > 0 && int.TryParse(versionParts[0], out version))
{
return version;
}
// unable to determine version
return -1;
}
}
public float Scale => (float)UIScreen.MainScreen.Scale;
2017-06-28 15:27:06 +03:00
public bool NfcEnabled => false;
public bool HasCamera => true;
2017-11-28 01:27:11 +03:00
public bool AutofillServiceSupported => false;
2017-11-29 23:47:43 +03:00
public bool HasFaceIdSupport
{
get
{
if(Version < 11)
{
return false;
}
var context = new LAContext();
2017-11-30 07:29:13 +03:00
if(!context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError e))
{
return false;
}
return context.BiometryType == LABiometryType.FaceId;
2017-11-29 23:47:43 +03:00
}
}
}
}