简体   繁体   中英

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.

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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM