Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent AVCaptureSession from crashing once user toggles Camera privacy settings

Tags:

ios

ios7.1

Been using AVCaptureSession to record barcodes, and it works well. I also have followed the advice on stack overflow (How to properly release an AVCaptureSession) to

[_session stopRunning];
[_prevLayer removeFromSuperlayer];
_prevLayer = nil;
_session = nil;

in ViewWillDisappear, with the hope that it properly releases the CaptureSession. (Other answers in SO refer to pre ARC time)

However, when I toggle the camera privacy settings for the App (E.g. from enabled to disabled, or vice versa), the App crashes. This is a problem because a user that doesn't originally enable Camera cannot do it retrospectively without it crashing. Is there anything else I need to do to prevent this from happening?

Thanks much!

like image 670
user3847136 Avatar asked Dec 12 '22 04:12

user3847136


1 Answers

No, there is nothing to do about this; this behavior will always cause the app to crash. The same thing occurs when you enable/disable Privacy options for letting an app search the iOS contact book, etc. If the user declines the initial Privacy request, and minimizes the app and goes to the Settings app and changes the Privacy setting, you will see that the app relaunches the next time you come back to it. This occurs any time you make a change to a Privacy setting for your respective app.

like image 187
klcjr89 Avatar answered May 16 '23 06:05

klcjr89