AvcaptureSession crash prevention after user switch camera privacy settings

Used by AVCaptureSession to record barcodes, and it works well. I also followed the recommendations on stack overflow ( How to properly release AVCaptureSession ) in

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

in ViewWillDisappear, hoping it will correctly issue the CaptureSession. (Other answers in SO refer to the period prior to ARC)

However, when I switch the camera’s privacy settings for the application (for example, from enabled to disabled or vice versa), the application crashes. This is a problem because a user who did not initially enable Camera cannot retrospectively do this without crashing it. Is there anything else I need to do to prevent this from happening?

Thank you so much!

+4
source share
1 answer

No, there is nothing to do with it; this behavior will always cause the application to crash. The same thing happens when you enable / disable privacy settings that allow you to search in an iOS contact, etc. If the user rejects the initial privacy request and minimizes the application and goes to the Settings application and changes the Privacy setting, you will see that the application restarts the next time you return to it. This happens every time you change the privacy settings for your respective application.

+12
source

Source: https://habr.com/ru/post/1548704/


All Articles