Search code examples
ioscamerarestrictions

How can I detect if camera is restricted by user


I'm doing an ios app with a button that launch the camera.

I want to enable/disable the button if the device has a camera available or not.

I want to detect if the device has a camera and also when the device has camera but it's restricted (with this) so you can't use it.

How can I detect these two options?

Thanks


Solution

  • As stated elsewhere, checking the AVAuthorizationStatus won't actually tell you if it's restricted, despite the presence of a "restricted" value in the enum. Instead, I have found that checking if source is enabled to be helpful:

    BOOL isCameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
    

    If isCameraAvailable is NO then the user has most likely disabled camera in Restrictions. See Detect existence of camera in iPhone app?