我的应用程序中使用card.io来扫描信用卡。它在iOS 9上运行良好。但在iOS 10上,该应用程序会崩溃,我无法在xcode 8 beta 2控制台中找到崩溃日志,因为它抛出了很多垃圾消息。
之后,我检查了隐私->设置,看看相机是否被禁用了,但我的应用程序没有出现在那个部分中。似乎iOS 10没有授权我的应用程序使用相机。
我使用以下代码请求权限:
-(BOOL)checkCameraPermissions{
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusAuthorized)
{
// start card-io
return YES;
}
else if(authStatus == AVAuthorizationStatusNotDetermined)
{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
{
if(granted)
{
//Start card-io
[self testIsNewCard];
}
}];
}
else if (authStatus == AVAuthorizationStatusRestricted)
{
//Alert
// Alert camera denied
UIAlertController *aCon=[UIAlertController alertControllerWithTitle:@"Camera denied" message:@"Camera cannot be used" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok =[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[aCon dismissViewControllerAnimated:YES completion:nil];
}];
[aCon addAction:ok];
[self presentViewController:aCon animated:YES completion:nil];
return NO;
}
return NO;
}
当我运行这段代码时,authStatus返回为AVAuthorizationStatusNotDetermined
,并且在进入requestAccessForMediaType:AVMediaTypeVideo
块后应用程序崩溃了。控制台中显示了大量的垃圾日志,我不知道如何找到崩溃消息。
编辑:我发现了一个选项,可以在xcode 8中禁用所有不必要的日志。答案发布在这里。但是即使禁用回溯调试,xcode仍然没有显示任何崩溃日志。我的xcode8只显示这个消息,然后应用程序就退出了:
App[1124:226447] [access] <private>
我也尝试重置了位置和隐私设置,但是当尝试请求媒体访问时应用程序仍会崩溃。 有任何想法原因是什么?