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

前端 未结 5 1293
南笙
南笙 2021-02-14 16:00

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 Ca

5条回答
  •  孤独总比滥情好
    2021-02-14 16:50

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

提交回复
热议问题