Teclado personalizado iOS: la cámara no funciona

Quiero crear un teclado personalizado, que actúe como un escáner de código de barras. Ya hice toda la codificación, pero la salida no es la esperada: me piden permisos de cámara (la primera vez), pero la cámara no envía ningún video a la vista.

Creo que podría haber algunas restricciones al usar teclados por razones de seguridad.

1.) Encienda la antorcha

-(void) turnFlashOn
{
    AVCaptureDevice *flashLight = [AVCaptureDevice
                                   defaultDeviceWithMediaType:AVMediaTypeVideo];
    if([flashLight isTorchAvailable] && [flashLight
                                         isTorchModeSupported:AVCaptureTorchModeOn])
    {
        BOOL success = [flashLight lockForConfiguration:nil];
        if(success){
            NSError *error;
            [flashLight setTorchMode:AVCaptureTorchModeOn];
            [flashLight setTorchModeOnWithLevel:1.0 error:&error];
            NSLog(@"Error: %@", error);
            [flashLight unlockForConfiguration];
            NSLog(@"flash turned on -> OK");

        }
        else
        {
            NSLog(@"flash turn on -> ERROR");
        }
    }

}

Esto me da esta salida de registro, pero no pasa nada con el flash:

Error: (null)
flash turned on -> OK

2.) Escanee el código de barras (parte de viewDidLoad)

    // SCANNER PART
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:@[AVMetadataObjectTypeQRCode, AVMetadataObjectTypeEAN13Code]];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];

camView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
previewLayer.frame = camView.layer.bounds;
[camView.layer addSublayer:previewLayer];
self.keyboard.barcodeView.clipsToBounds=YES;
camView.center = CGPointMake(self.keyboard.barcodeView.frame.size.width/2, self.keyboard.barcodeView.frame.size.height/2);

[self.keyboard.barcodeView addSubview:camView];

Y si presiono una tecla especial en mi teclado, esta se llama:

-(vo,id)scanBarcodeNow{
AudioServicesPlaySystemSound(systemSoundTock);
NSLog(@"Start scanning...");
self.keyboard.barcodeView.hidden=false;
[self.keyboard.barcodeView addSubview:camView];
[self.keyboard.barcodeView setBackgroundColor:[UIColor redColor]];
[self.captureSession startRunning];

}

Lo único que sucede es que el keyboard.barcodeView cambia su color de fondo a rojo. He hecho esto para ver, que todo el cableado que he hecho debería estar bien. Pero no se muestra ningún video de la cámara ...

¿Puede alguien ayudarme?

Respuestas a la pregunta(1)

Su respuesta a la pregunta