为什么我的iOS应用程序不询问用户访问相机的权限? [英] Why my iOS app does not ask user permission to access camera?

查看:525
本文介绍了为什么我的iOS应用程序不询问用户访问相机的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了iOS应用,它使用相机。 AVCaptureDeviceInput用于连接摄像机。
我将授权状态检查为

I develop iOS app and it uses camera. AVCaptureDeviceInput is used to interface to camera. I checked Authorisation status as

- (void)checkDeviceAuthorizationStatus
{
    NSString *mediaType = AVMediaTypeVideo;

    [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
        if (granted)
        {
            //Granted access to mediaType
            [self setDeviceAuthorized:YES];
        }
        else
        {
            //Not granted access to mediaType
            dispatch_async(dispatch_get_main_queue(), ^{
                [[[UIAlertView alloc] initWithTitle:@"AVCam!"
                                            message:@"AVCam doesn't have permission to use Camera, please change privacy settings"
                                           delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil] show];
                [self setDeviceAuthorized:NO];
            });
        }
    }];
}

启动应用程序时,为什么它不要求用户访问权限相机?
因此,该应用程序不会出现在设置/隐私/相机中,无法手动允许访问相机。
然后显示此错误 AVCam没有使用相机的权限,请更改隐私设置 并且应用无法使用相机。

When I launch the application, why it does not ask user permission for access to the camera? So the app does not appear in settings/privacy/camera to manually allow to access camera. Then show this error "AVCam doesn't have permission to use Camera, please change privacy settings" and app can't use the camera.

编辑:
这意味着该应用程序未经用户许可不得访问相机。
不仅相机,相机胶卷也有同样的问题。

That means the app is not allowed to access the camera without asking user permission. Not only camera, camera-roll also has the same problem.

所有这些事情都是在我重置设置 /重置 /重置所有设置中的设置之后发生的。

All these things happened after I reset settings in Settings/Reset/Rest All Settings. Before that the app was working well.

推荐答案

该问题现在已解决。我需要逐步追溯,并花了很长时间解决问题。
有些人建议包括
NSCamerausageDescription密钥。实际上,对于装有iOS 7及更高版本的设备而言,这是必需的。我已包含密钥,但仍未要求用户许可。
最后,我在Info.plist上发现了问题。
还有一些额外的行,我删除了三行。不知道它们与我的问题有什么关系。
我删除的是

The problem is solved now. I need to trace back step by step and took me long time to solve the problem. Some people suggested to include NSCamerausageDescription Key. Actually it is necessary for devices with iOS 7 and above. I included the Key but still user permission is not asked yet. Finally I found the problem at Info.plist. There are some extra lines and I deleted three lines. Not sure how they are related to my problem. Those I deleted are

(1)获取信息字符串

(2)捆绑显示名称

(3)应用类别

在删除info.plist中的这三行之后。然后,该应用会询问用户权限。关键是您可能需要检查Info.plist中是否存在此类问题。

After deleting these three lines in the info.plist. Then the app asks the user permission. The point is that you may need to check your Info.plist for such problem.

这篇关于为什么我的iOS应用程序不询问用户访问相机的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆