iOS Camera permissions doesn't appear under settings in some devices









up vote
9
down vote

favorite
3












I'm having some issues trying to use the camera. The problem is that some devices show me the Camera entry under settings, and some others don't. In those devices where the Camera switch doesn't appear, I'm not able to use the camera, since it doesn't have permissions, and it also doesn't appear under settings to enable them.



This is how it looks on a device that works:



enter image description here



And this is how it looks in devices that doesn't work.



enter image description here



When I took those screenshots, the application should've asked for permissions already, but it didn't.



I also verified that those devices doesn't have Restrictions enabled.



Any ideas?



UPDATE 1: Added code



This is the code I'm using to show the camera (it's under a custom view, not the native camera view controller)



self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if(videoInput)

[self.captureSession addInput:videoInput];

else

NSLog(@"Error: %@", error);


AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
[self.captureSession addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self
queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeQRCode]];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
previewLayer.frame = self.view.layer.bounds;
UIView * previewView = [[UIView alloc] initWithFrame:self.view.frame];
[previewView.layer addSublayer:previewLayer];
[self.view addSubview:previewView];
[self.view sendSubviewToBack:previewView];

[self.captureSession startRunning];









share|improve this question























  • Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
    – Aaron Brager
    Sep 1 '15 at 13:02










  • Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
    – lucaslt89
    Sep 1 '15 at 13:07










  • I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
    – durazno
    Nov 24 '15 at 23:24










  • Aaron's answer worked for me.
    – lucaslt89
    Nov 24 '15 at 23:25










  • Please try this solution stackoverflow.com/a/34526211 It worked for me.
    – user3236605
    Jun 10 '16 at 2:37














up vote
9
down vote

favorite
3












I'm having some issues trying to use the camera. The problem is that some devices show me the Camera entry under settings, and some others don't. In those devices where the Camera switch doesn't appear, I'm not able to use the camera, since it doesn't have permissions, and it also doesn't appear under settings to enable them.



This is how it looks on a device that works:



enter image description here



And this is how it looks in devices that doesn't work.



enter image description here



When I took those screenshots, the application should've asked for permissions already, but it didn't.



I also verified that those devices doesn't have Restrictions enabled.



Any ideas?



UPDATE 1: Added code



This is the code I'm using to show the camera (it's under a custom view, not the native camera view controller)



self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if(videoInput)

[self.captureSession addInput:videoInput];

else

NSLog(@"Error: %@", error);


AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
[self.captureSession addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self
queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeQRCode]];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
previewLayer.frame = self.view.layer.bounds;
UIView * previewView = [[UIView alloc] initWithFrame:self.view.frame];
[previewView.layer addSublayer:previewLayer];
[self.view addSubview:previewView];
[self.view sendSubviewToBack:previewView];

[self.captureSession startRunning];









share|improve this question























  • Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
    – Aaron Brager
    Sep 1 '15 at 13:02










  • Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
    – lucaslt89
    Sep 1 '15 at 13:07










  • I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
    – durazno
    Nov 24 '15 at 23:24










  • Aaron's answer worked for me.
    – lucaslt89
    Nov 24 '15 at 23:25










  • Please try this solution stackoverflow.com/a/34526211 It worked for me.
    – user3236605
    Jun 10 '16 at 2:37












up vote
9
down vote

favorite
3









up vote
9
down vote

favorite
3






3





I'm having some issues trying to use the camera. The problem is that some devices show me the Camera entry under settings, and some others don't. In those devices where the Camera switch doesn't appear, I'm not able to use the camera, since it doesn't have permissions, and it also doesn't appear under settings to enable them.



This is how it looks on a device that works:



enter image description here



And this is how it looks in devices that doesn't work.



enter image description here



When I took those screenshots, the application should've asked for permissions already, but it didn't.



I also verified that those devices doesn't have Restrictions enabled.



Any ideas?



UPDATE 1: Added code



This is the code I'm using to show the camera (it's under a custom view, not the native camera view controller)



self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if(videoInput)

[self.captureSession addInput:videoInput];

else

NSLog(@"Error: %@", error);


AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
[self.captureSession addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self
queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeQRCode]];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
previewLayer.frame = self.view.layer.bounds;
UIView * previewView = [[UIView alloc] initWithFrame:self.view.frame];
[previewView.layer addSublayer:previewLayer];
[self.view addSubview:previewView];
[self.view sendSubviewToBack:previewView];

[self.captureSession startRunning];









share|improve this question















I'm having some issues trying to use the camera. The problem is that some devices show me the Camera entry under settings, and some others don't. In those devices where the Camera switch doesn't appear, I'm not able to use the camera, since it doesn't have permissions, and it also doesn't appear under settings to enable them.



This is how it looks on a device that works:



enter image description here



And this is how it looks in devices that doesn't work.



enter image description here



When I took those screenshots, the application should've asked for permissions already, but it didn't.



I also verified that those devices doesn't have Restrictions enabled.



Any ideas?



UPDATE 1: Added code



This is the code I'm using to show the camera (it's under a custom view, not the native camera view controller)



self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if(videoInput)

[self.captureSession addInput:videoInput];

else

NSLog(@"Error: %@", error);


AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
[self.captureSession addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self
queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeQRCode]];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
previewLayer.frame = self.view.layer.bounds;
UIView * previewView = [[UIView alloc] initWithFrame:self.view.frame];
[previewView.layer addSublayer:previewLayer];
[self.view addSubview:previewView];
[self.view sendSubviewToBack:previewView];

[self.captureSession startRunning];






ios iphone ipad ios-camera






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 1 '15 at 13:04

























asked Sep 1 '15 at 12:58









lucaslt89

1,9391525




1,9391525











  • Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
    – Aaron Brager
    Sep 1 '15 at 13:02










  • Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
    – lucaslt89
    Sep 1 '15 at 13:07










  • I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
    – durazno
    Nov 24 '15 at 23:24










  • Aaron's answer worked for me.
    – lucaslt89
    Nov 24 '15 at 23:25










  • Please try this solution stackoverflow.com/a/34526211 It worked for me.
    – user3236605
    Jun 10 '16 at 2:37
















  • Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
    – Aaron Brager
    Sep 1 '15 at 13:02










  • Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
    – lucaslt89
    Sep 1 '15 at 13:07










  • I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
    – durazno
    Nov 24 '15 at 23:24










  • Aaron's answer worked for me.
    – lucaslt89
    Nov 24 '15 at 23:25










  • Please try this solution stackoverflow.com/a/34526211 It worked for me.
    – user3236605
    Jun 10 '16 at 2:37















Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
– Aaron Brager
Sep 1 '15 at 13:02




Camera will only appear there once your app requests permission. Can you show the code you're using to request permission?
– Aaron Brager
Sep 1 '15 at 13:02












Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
– lucaslt89
Sep 1 '15 at 13:07




Added. Doesn't that code ask automatically for permissions when I start the capture session? There's other place in the app where I'm using a UIImagePickerController to take photos. Maybe I'm not handling permissions correctly, but if I opened the UIImagePickerController before, then permissions are enabled?
– lucaslt89
Sep 1 '15 at 13:07












I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
– durazno
Nov 24 '15 at 23:24




I'm having the same issue and very desperate for a solution. Please let me know if you've found a way to solve this...!
– durazno
Nov 24 '15 at 23:24












Aaron's answer worked for me.
– lucaslt89
Nov 24 '15 at 23:25




Aaron's answer worked for me.
– lucaslt89
Nov 24 '15 at 23:25












Please try this solution stackoverflow.com/a/34526211 It worked for me.
– user3236605
Jun 10 '16 at 2:37




Please try this solution stackoverflow.com/a/34526211 It worked for me.
– user3236605
Jun 10 '16 at 2:37












3 Answers
3






active

oldest

votes

















up vote
8
down vote



accepted










You need to request permission before opening a session. Use



[AVCaptureDevice requestAccessForMediaType:completionHandler:]





share|improve this answer


















  • 1




    No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
    – durazno
    Nov 24 '15 at 23:22











  • I am also having the same issue.the app doesn't request permission .Have you corrected it?
    – abhi1992
    Dec 14 '15 at 5:35

















up vote
3
down vote













Step 1: Give a proper camera message access message on your info.plist using the following key (without quotes)



"Privacy - Camera Usage Description"


Step 2 : For objective-C/SWIFT you need to request a camera access permission



OBJECTIVE-C



[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)

if (granted == true)

//[self presentViewController : picker animated:YES completion:NULL];
//Do your stuff


else

UIAlertView *cameraAlert = [[UIAlertView alloc]initWithTitle:STR_APPLICATION_TITLE
message:STR_ALERT_CAMERA_DENIED_MESSAGE
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[cameraAlert show];

NSLog(@"denied");


];


SWIFT



AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: (videoGranted: Bool) -> Void in
if (videoGranted)
//Do Your stuff here

else
// Rejected Camera

)





share|improve this answer



























    up vote
    0
    down vote













    I had the same problem until I changed my camera type to wide:



     let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)





    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32332313%2fios-camera-permissions-doesnt-appear-under-settings-in-some-devices%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      8
      down vote



      accepted










      You need to request permission before opening a session. Use



      [AVCaptureDevice requestAccessForMediaType:completionHandler:]





      share|improve this answer


















      • 1




        No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
        – durazno
        Nov 24 '15 at 23:22











      • I am also having the same issue.the app doesn't request permission .Have you corrected it?
        – abhi1992
        Dec 14 '15 at 5:35














      up vote
      8
      down vote



      accepted










      You need to request permission before opening a session. Use



      [AVCaptureDevice requestAccessForMediaType:completionHandler:]





      share|improve this answer


















      • 1




        No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
        – durazno
        Nov 24 '15 at 23:22











      • I am also having the same issue.the app doesn't request permission .Have you corrected it?
        – abhi1992
        Dec 14 '15 at 5:35












      up vote
      8
      down vote



      accepted







      up vote
      8
      down vote



      accepted






      You need to request permission before opening a session. Use



      [AVCaptureDevice requestAccessForMediaType:completionHandler:]





      share|improve this answer














      You need to request permission before opening a session. Use



      [AVCaptureDevice requestAccessForMediaType:completionHandler:]






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Sep 19 '17 at 9:39









      Pang

      6,8021563100




      6,8021563100










      answered Sep 1 '15 at 13:12









      Aaron Brager

      52.4k14111215




      52.4k14111215







      • 1




        No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
        – durazno
        Nov 24 '15 at 23:22











      • I am also having the same issue.the app doesn't request permission .Have you corrected it?
        – abhi1992
        Dec 14 '15 at 5:35












      • 1




        No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
        – durazno
        Nov 24 '15 at 23:22











      • I am also having the same issue.the app doesn't request permission .Have you corrected it?
        – abhi1992
        Dec 14 '15 at 5:35







      1




      1




      No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
      – durazno
      Nov 24 '15 at 23:22





      No this is not true. "Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput." and it does exactly that if you don't manually ask for permission and also you do get asked when manually done. However I'm having the same issue with lucaslt89. Even after resetting location & privacy, the app doesn't request permission and the same result when manually called [AVCaptureDevice requestAccessForMediaType:completionHandler:]. This happens with some devices but with some others no such issue occurs. WHY?!!
      – durazno
      Nov 24 '15 at 23:22













      I am also having the same issue.the app doesn't request permission .Have you corrected it?
      – abhi1992
      Dec 14 '15 at 5:35




      I am also having the same issue.the app doesn't request permission .Have you corrected it?
      – abhi1992
      Dec 14 '15 at 5:35












      up vote
      3
      down vote













      Step 1: Give a proper camera message access message on your info.plist using the following key (without quotes)



      "Privacy - Camera Usage Description"


      Step 2 : For objective-C/SWIFT you need to request a camera access permission



      OBJECTIVE-C



      [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)

      if (granted == true)

      //[self presentViewController : picker animated:YES completion:NULL];
      //Do your stuff


      else

      UIAlertView *cameraAlert = [[UIAlertView alloc]initWithTitle:STR_APPLICATION_TITLE
      message:STR_ALERT_CAMERA_DENIED_MESSAGE
      delegate:self
      cancelButtonTitle:@"OK"
      otherButtonTitles:nil,nil];
      [cameraAlert show];

      NSLog(@"denied");


      ];


      SWIFT



      AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: (videoGranted: Bool) -> Void in
      if (videoGranted)
      //Do Your stuff here

      else
      // Rejected Camera

      )





      share|improve this answer
























        up vote
        3
        down vote













        Step 1: Give a proper camera message access message on your info.plist using the following key (without quotes)



        "Privacy - Camera Usage Description"


        Step 2 : For objective-C/SWIFT you need to request a camera access permission



        OBJECTIVE-C



        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)

        if (granted == true)

        //[self presentViewController : picker animated:YES completion:NULL];
        //Do your stuff


        else

        UIAlertView *cameraAlert = [[UIAlertView alloc]initWithTitle:STR_APPLICATION_TITLE
        message:STR_ALERT_CAMERA_DENIED_MESSAGE
        delegate:self
        cancelButtonTitle:@"OK"
        otherButtonTitles:nil,nil];
        [cameraAlert show];

        NSLog(@"denied");


        ];


        SWIFT



        AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: (videoGranted: Bool) -> Void in
        if (videoGranted)
        //Do Your stuff here

        else
        // Rejected Camera

        )





        share|improve this answer






















          up vote
          3
          down vote










          up vote
          3
          down vote









          Step 1: Give a proper camera message access message on your info.plist using the following key (without quotes)



          "Privacy - Camera Usage Description"


          Step 2 : For objective-C/SWIFT you need to request a camera access permission



          OBJECTIVE-C



          [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)

          if (granted == true)

          //[self presentViewController : picker animated:YES completion:NULL];
          //Do your stuff


          else

          UIAlertView *cameraAlert = [[UIAlertView alloc]initWithTitle:STR_APPLICATION_TITLE
          message:STR_ALERT_CAMERA_DENIED_MESSAGE
          delegate:self
          cancelButtonTitle:@"OK"
          otherButtonTitles:nil,nil];
          [cameraAlert show];

          NSLog(@"denied");


          ];


          SWIFT



          AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: (videoGranted: Bool) -> Void in
          if (videoGranted)
          //Do Your stuff here

          else
          // Rejected Camera

          )





          share|improve this answer












          Step 1: Give a proper camera message access message on your info.plist using the following key (without quotes)



          "Privacy - Camera Usage Description"


          Step 2 : For objective-C/SWIFT you need to request a camera access permission



          OBJECTIVE-C



          [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)

          if (granted == true)

          //[self presentViewController : picker animated:YES completion:NULL];
          //Do your stuff


          else

          UIAlertView *cameraAlert = [[UIAlertView alloc]initWithTitle:STR_APPLICATION_TITLE
          message:STR_ALERT_CAMERA_DENIED_MESSAGE
          delegate:self
          cancelButtonTitle:@"OK"
          otherButtonTitles:nil,nil];
          [cameraAlert show];

          NSLog(@"denied");


          ];


          SWIFT



          AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: (videoGranted: Bool) -> Void in
          if (videoGranted)
          //Do Your stuff here

          else
          // Rejected Camera

          )






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 20 '16 at 10:35









          Vicky

          9061313




          9061313




















              up vote
              0
              down vote













              I had the same problem until I changed my camera type to wide:



               let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)





              share|improve this answer
























                up vote
                0
                down vote













                I had the same problem until I changed my camera type to wide:



                 let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I had the same problem until I changed my camera type to wide:



                   let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)





                  share|improve this answer












                  I had the same problem until I changed my camera type to wide:



                   let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 15:08









                  jimijon

                  5621821




                  5621821



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32332313%2fios-camera-permissions-doesnt-appear-under-settings-in-some-devices%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                      Museum of Modern and Contemporary Art of Trento and Rovereto