我在应用程序商店中有一个使用 Touch ID 的 iPhone 应用程序。如果启用了 Touch ID,则用户将通过它进行身份验证,否则用户需要输入 PIN 码才能登录应用程序。
iOS 10.1发布后,当我检查崩溃报告时,崩溃次数有所增加。从崩溃报告来看,它指向 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]
,当我在 Xcode 中打开应用程序时,它的重点是 [selfmissViewControllerAnimated:YES finish:nil];
.
我编写的代码如下:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"User is authenticated successfully");
[self dismissViewControllerAnimated:YES completion:nil];
} else {
}];
}
}
当我在 iPhone 6、IOS 10 中测试时,一切正常。不知道如何模拟该问题。
任何人都可以弄清楚我是否遗漏了什么吗?请帮我解决这个崩溃问题。
最佳答案
通常完成处理程序不在主线程上运行。所有与 UI 相关的操作都必须在主线程上完成(包括关闭 View Controller )。
我建议在主线程 block 上添加解雇行,如下所示:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"User is authenticated successfully");
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
[self dismissViewControllerAnimated:YES completion:nil];
}];
} else {
}];
}
}
关于iPhone 应用程序崩溃并出现错误 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary :],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39695328/