问题描述
我需要检查苹果设备是否在我的 xamarin.iOS 项目中激活了某种身份验证方法。例如在我的 xamarin Android 项目中,我可以这样做:
public bool ExistsLocalAuthenticacion() {
KeyguardManager keyguardManager = (KeyguardManager)Android.App.Application.Context.GetSystemService("keyguard");
if (keyguardManager.IsDeviceSecure)
return true;
else
return false;
}
我需要做类似的事情,但在 iOS 项目中,这可能吗?
解决方法
在 CanEvaluatePolicy() 上使用 deviceOwnerAuthentication:
var context = new LAContext();
if (context.CanEvaluatePolicy(LAPolicy.deviceOwnerAuthentication,out var error))
{
return true;
}
else
{
return false;
//handle error
}