2016-08-24 05:43:17 +03:00
|
|
|
|
using Bit.App.Abstractions;
|
2017-11-29 23:47:43 +03:00
|
|
|
|
using Foundation;
|
|
|
|
|
using LocalAuthentication;
|
2016-08-24 05:43:17 +03:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-26 04:43:47 +03:00
|
|
|
|
public float Scale => (float)UIScreen.MainScreen.Scale;
|
2017-06-28 15:27:06 +03:00
|
|
|
|
public bool NfcEnabled => false;
|
2017-09-07 07:33:19 +03:00
|
|
|
|
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.TypeFaceId;
|
2017-11-29 23:47:43 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-24 05:43:17 +03:00
|
|
|
|
}
|
|
|
|
|
}
|