[英]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.