Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In iOS 7, an app could access the camera before getting authorize of the user. When an app accesses the camera the first time, iOS show an alert view to ask user. Users could also set the authorize in <code>Settings--Privacy--Camera--[Your app's name]</code>.</p> <p>The camera will stay in a black blank view if the switch is off.</p> <ol> <li><p>If you call the camera by using <code>AVCaptureDeviceInput</code>, you can check like:</p> <pre><code>NSError *inputError = nil; AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&amp;inputError]; if (inputError &amp;&amp; inputError.code == AVErrorApplicationIsNotAuthorizedToUseDevice) { // not authorized } </code></pre></li> <li><p>If you call by using <code>UIImagePickerController</code>, I am still looking for a way to check whether got the authorize.</p> <p>I tried these two methods:</p> <pre><code>[UIImagePickerController isSourceTypeAvailable:] [UIImagePickerController isCameraDeviceAvailable:] </code></pre> <p>but they did't work that they all returned YES.</p></li> </ol> <p><strong>UPDATE</strong></p> <p>Thanks for Scott's expanding. <code>[AVCaptureDevice authorizationStatusForMediaType:]</code> is a better way to check.</p> <pre><code>AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (authStatus == AVAuthorizationStatusAuthorized) { // successful } else { // failed, such as // AVAuthorizationStatusNotDetermined // AVAuthorizationStatusRestricted // AVAuthorizationStatusNotDetermined } </code></pre> <p>But remember to check the iOS version, because <code>[AVCaptureDevice authorizationStatusForMediaType:]</code> and <code>AVAuthorizationStatus</code> are available above iOS 7.</p> <pre><code>if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 7.0) { // code for AVCaptureDevice auth checking } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload