gpt4 book ai didi

ios - 使用密码或 TouchID 锁定特定应用程序

转载 作者:行者123 更新时间:2023-11-29 12:20:14 27 4
gpt4 key购买 nike

我想用 Passcode 或 TouchID 锁定特定应用程序,如 facebook、whatsapp 等,这样未经授权的用户就无法访问我想保护的应用程序。

我在网上没有找到任何方法,不确定是否可以锁定任何特定的应用程序?

最佳答案

在应用程序的开始实现一个登录屏幕,对于touchID(touchID是iOS8+)你可以使用这个代码:

LAContext *context = [[LAContext alloc] init];
context.localizedFallbackTitle = @"Enter PIN";
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"PIN Authentication" reply:^(BOOL success, NSError *error) {
if (success)
{
//success, let's get started!
}
else if (error.code == LAErrorUserCancel)
{
NSLog(@"Authentication failed: %@", @"TouchID authentication cancelled");
}
else if (error.code == LAErrorAuthenticationFailed)
{
NSLog(@"Authentication failed: %@", @"TouchID authentication failed");
}
else if (error.code == LAErrorUserFallback)
{
NSLog(@"Authentication failed: %@", @"TouchID authentication pin authentification fallback selected");
}
else if (error.code == LAErrorSystemCancel)
{
NSLog(@"Authentication failed: %@", @"Touch authentication was canceled by system (e.g. another application went to foreground).");
}
else if (error.code == LAErrorPasscodeNotSet)
{
NSLog(@"Authentication failed: %@", @"Touch authentication could not start, because passcode is not set on the device.");
}
else if (error.code == LAErrorTouchIDNotAvailable)
{
NSLog(@"Authentication failed: %@", @"Touch authentication could not start, because Touch ID is not available on the device.");
}
else if (error.code == LAErrorTouchIDNotEnrolled)
{
NSLog(@"Authentication failed: %@", @"Touch authentication could not start, because Touch ID has no enrolled fingers.");
}
else
{
NSLog(@"Authentication failed: %@", @"Touch ID has not been setup or system has cancelled");
}
}];

关于ios - 使用密码或 TouchID 锁定特定应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30869334/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com