简体   繁体   English

为什么我的 iOS 应用程序不要求用户访问相机的权限?

[英]Why my iOS app does not ask user permission to access camera?

I develop iOS app and it uses camera.我开发了 iOS 应用程序,它使用了相机。 AVCaptureDeviceInput is used to interface to camera. AVCaptureDeviceInput 用于连接到相机。 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];
            });
        }
    }];
}

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.然后显示此错误"AVCam doesn't have permission to use Camera, please change privacy settings"并且应用程序无法使用相机。

EDIT: 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.在此之前,该应用程序运行良好。

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.有些人建议包含 NSCamerausageDescription Key。 Actually it is necessary for devices with iOS 7 and above.实际上,iOS 7 及更高版本的设备是必需的。 I included the Key but still user permission is not asked yet.我包含了密钥,但仍然没有询问用户权限。 Finally I found the problem at Info.plist.最后我在 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)Get info string (1)获取信息字符串

(2)Bundle display name (2)Bundle 显示名称

(3)Application Category (3)应用类别

After deleting these three lines in the info.plist.在info.plist中删除这三行后。 Then the app asks the user permission.然后应用程序询问用户许可。 The point is that you may need to check your Info.plist for such problem.关键是您可能需要检查您的 Info.plist 是否存在此类问题。

您需要将您的应用程序名称放在 info.plist 的“Bundle display name”中

Well looking at above contradictory solutions - to remove and to add bundle display name - makes me think of the cause of this bug.看看上面矛盾的解决方案 - 删除和添加包显示名称 - 让我想到了这个错误的原因。 I guess this (Apple) bug appears only on devices that had the same app installed at the time it didn't have camera permissions (older versions without camera functions or just bad testflight versions).我猜这个(Apple)错误只出现在安装了相同应用程序的设备上,当时它没有相机权限(没有相机功能的旧版本或只是糟糕的 testflight 版本)。 So if you just delete and install from scratch the bugged app permissions will become okay.因此,如果您只是从头开始删除和安装,则被窃听的应用程序权限将变得没问题。 Speaking of workaround without uninstalling the existing app, if you change the bundle description (delete or add) in plist then iOS will use the new plist with permissions over already installed as we expect it should.说到不卸载现有应用程序的解决方法,如果您更改 plist 中的包描述(删除或添加),那么 iOS 将使用新的 plist,其权限超过已安装的权限,正如我们所期望的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的应用程序不显示提示询问访问用户位置的提示? - Why does my app not display the alert to ask to access user's location? 弹出窗口不会要求在iOS 12中访问相机的权限 - Popup is not coming to ask permission to access camera in iOS 12 不要求用户许可以英语以外的其他语言访问相机 - Not ask user permission to access camera in other languages than English 请求访问相机胶卷的权限 - Ask permission to access Camera Roll 为什么当应用程序不要求FB SDK时,iOS上的FB SDK要求获得好友列表的许可 - Why FB SDK on iOS asks for permission for Friend List, when app does not ask for it 有没有办法在用户已经在 iOS 上拒绝它之后要求用户访问相机? - Is there a way to ask user for Camera access after they have already denied it on iOS? 为什么我的 iOS 应用程序显示它需要“本地网络”权限? - Why does my iOS app show it needs "Local Network" permission? 默认情况下,我的应用程序具有摄像头访问权限。如何关闭它并请求权限? - My application has the camera access permission by default.How can i turned it off and ask for permission? flutter 弹出窗口未请求访问相机的权限 - flutter popup is not coming to ask permission to access camera 即使我要求在后台更新位置,为什么我的iOS应用程序会被杀死? - Why does my iOS app get killed even though I ask for location updates in the background?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM