6

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];
            });
        }
    }];
}

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.

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.

batuman
  • 7,066
  • 26
  • 107
  • 229
  • I think somehow You have not allowed the camera to start , once it is set the permission alert will not come again you can try by changing the device date. – Reshmi Majumder Feb 19 '16 at 08:16
  • Have a look at this http://stackoverflow.com/questions/26070393/is-there-a-way-to-ask-user-for-camera-access-after-they-have-already-denied-it-o – sbarow Feb 19 '16 at 08:17
  • @ReshmiMajumder, today is 19. I deleted the app. Change phone date to 21. Then switch off the phone. Then switch on. Reinstall the app. But still does not ask. Why it is over 24 hours already? – batuman Feb 19 '16 at 08:23
  • @sbarow, that link shows to bring the user to setting page. But the app doesn't ask permission, then settings does not have anything to change camera access for my app. According to the document is, after asking the permission, these user setting comes out. Now the app does not ask permission. – batuman Feb 19 '16 at 08:55
  • @batuman that link actually shows checking what the current auth status is, then processing according to that. Have you checked what your auth status is? – sbarow Feb 19 '16 at 09:27
  • @sbarow, important thing is requestAccessForMediaType (i also did that as mentioned above) and OS ask the user for permission. Now OS does not ask user for permission. – batuman Feb 19 '16 at 09:35
  • Other discussions are found here (https://discussions.apple.com/thread/6638176?start=15&tstart=0). Looks like OS bug. They also faced the same problem. For me is after, I reset settings in Settings/Reset/Rest All Settings. Then this problem came out. – batuman Feb 19 '16 at 09:43

3 Answers3

6

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)Get info string

(2)Bundle display name

(3)Application Category

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.

batuman
  • 7,066
  • 26
  • 107
  • 229
  • 2
    Wow... this actually worked for me as well. In my case I just needed to remove the Bundle Display Name, and now it is asking for camera permissions where before it wasn't. NSCameraUsageDescriptionKey has been there all along. – gregtzar Mar 20 '17 at 06:13
  • 1
    Removing Bundle Display Name from the plist and then running the app worked for me as well. Then I undid the removal, deleted the app from the device and reran, and now the camera permissions alert shows. This is on iPhone 6s with iOS 12.0.1. Very strange. – Robert Hartman May 09 '19 at 12:54
0

You need to put the name of your app in "Bundle display name" in info.plist

Anibal Lamego
  • 241
  • 1
  • 8
0

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

Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50