Torch in background

断了今生、忘了曾经 提交于 2019-12-25 02:26:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!