0

How can I detect "LED Flash for Alerts" (from Settings) status in code? I have tried:

AVCaptureDevice *torched=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];   

BOOL test = torched.torchMode;
BOOL test1 = torched.flashMode;

But it seams that it is not what I need.

revolutionkpi
  • 2,632
  • 10
  • 45
  • 84

1 Answers1

0

Do like this,

BOOL test=NO;
BOOL test1=NO;

Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    if ([device hasTorch] && [device hasFlash]){
       if(device.flashMode==AVCaptureFlashModeOn)
          NSLog(@"ON");
       else
          NSLog(@"OFF");
    }
}

Hope it will helps you....

Venk
  • 5,949
  • 9
  • 41
  • 52