问题
Is this possible to make torch lighting when app is in background?
This is what I do to turn it on:
AVCaptureSession *session = [AVCaptureSession new];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[session beginConfiguration];
[device lockForConfiguration:nil];
device.torchMode = AVCaptureTorchModeOn;
[device unlockForConfiguration];
[session commitConfiguration];
[session startRunning];
But when app goes to background torch is automatically turned off. And I cannot get back the light from background.
回答1:
When in background your application doesn't work or get any messages from the system. The only cases when this is allowed are:
navigation application
audio player
Internet telephony
Unless you are designing any of the above you can not flash the user with anything. If you only want to notify the user about something, you can create a notifier that will pop a message in the users window even if your application is in the background or entirely off. the user can click the message and then he will be back to your application.Exact answer is no unless Jailbroken
来源:https://stackoverflow.com/questions/25485556/torch-in-background