简体   繁体   English

检测用户何时拒绝访问摄像头

[英]Detect when user denies access to camera

NOTE: My questions is not a duplicate of questions asking HOW to detect if the user has denied access. 注意:我的问题与要求如何检测用户是否拒绝访问的问题不重复。

I saw a lot of code on HOW to detect if the user has given access to the camera, but I'd need to know WHEN the user denies access. 我在HOW上看到很多代码来检测用户是否已经访问了摄像头,但我需要知道用户何时拒绝访问。

My scenario is the next: 我的情景是下一个:

User opens view A, A asks for access to the camera, pop up appears, user denies access, user is redirected to B. 用户打开视图A,A要求访问摄像头,弹出,用户拒绝访问,用户被重定向到B.

Is this possible? 这可能吗?

Actually, there's a way of doing it: 实际上,有一种方法可以做到:

 [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
        if(granted){
            NSLog(@"Granted access");
        } else {
            NSLog(@"Not granted access");
        }
    }];

As of now you can use applicationWillResignActive: and applicationDidBecomeActive: , verify whether the AVAuthorizationStatus 's been changed and do whatever is needed. 截至目前,您可以使用applicationWillResignActive:applicationDidBecomeActive: ,验证AVAuthorizationStatus是否已更改并执行所需操作。 This isn't a future-proof solution, as the new iOS versions might not bring the app to background when asking for camera permissions, however any modifications to UIAlertView are even worse for that matter. 这不是一个面向未来的解决方案,因为新的iOS版本可能在要求摄像机权限时不会将应用程序带到后台,但是对UIAlertView任何修改都更糟糕。

暂无
暂无

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

相关问题 当用户拒绝访问iOS中的摄像头时,Cordova相机插件会显示黑屏 - Cordova camera plugin displays a black screen when the user denies access to the camera in iOS 如果用户以代号拒绝访问相机,您可以从代码中找出 - If a user denies access to the camera in codename one can you find out from code 当用户拒绝在Google地图中访问位置时,如何显示用户的当前国家/地区? - How can i show user's current country when user denies location access in Google map? 如何检测用户已单击“不允许访问摄像头” - How to detect user has clicked Don't Allow access to camera 当用户拒绝推送授权时,ios静默推送通知 - ios silent push notification when user denies Push Authorization UnauthorizedAccessException:访问路径被拒绝 Ios - UnauthorizedAccessException: Access to the path is denies Ios 当用户允许iOS中的摄像头访问警报时如何获得通知? - How to get notified when user allows the camera access alert in iOS? 当用户选择允许访问iOS中的Camera时收到通知 - Get notified when the user makes selection for allowing access to Camera in iOS 当用户在UIImagePickerController中拒绝移动和缩放后对照片的权限时,iOS应用程序崩溃 - iOS App crashes when user denies permission to Photos after Move & Scale in UIImagePickerController iOS Facebook SDK 3.1 openActiveSessionWithReadPermissions:检测用户何时未授予访问权限 - iOS Facebook SDK 3.1 openActiveSessionWithReadPermissions: Detect when user is not granting access
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM