I recalled that there was no straightforward LED API back when iOS 3.x was in use. A whole video capture session had to be started. It turns out that this is the only option for the iPhone 11; however. If you know of any that don't call for this, please let me know.
This is the fix I've tried. Because I used Objective C rather than Swift in this older project from 2009, I'm utilising it here. You can quickly locate Swift code to begin video capturing (ignore the output; it should still function properly).
AVCaptureSession* session = [[AVCaptureSession alloc] init];
AVCaptureDevice *inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&error];
if ([session canAddInput:deviceInput]) {
[session addInput:deviceInput];
}
AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
CALayer *rootLayer = self.view.layer;
[rootLayer setMasksToBounds:YES];
CGRect frame = self.view.frame;
[previewLayer setFrame:frame];
[rootLayer insertSublayer:previewLayer atIndex:0];
//This is where you'd save the video with AVCaptureVideoDataOutput but of course we don't.
[session startRunning];
And after this you just start the LED as usual:
NSError *error = nil;
if ([inputDevice isTorchModeSupported:AVCaptureTorchModeOn])
[inputDevice setTorchModeOnWithLevel:1.0 error:&error];
This gets maximum brightness on my iPhone 11 Pro. I am now looking for the same solution without having to use the video capture (which obviously uses battery AND requires a permission, which users may not like. It needs to be explained well).