Camera Access Crash

I am accessing the camera via my app and have read that I need to request permission via a plist entry but it is still crashing.

I have the following, what needs changing?

<?xml version="1.0" encoding="UTF-8"?> NSCameraUsageDescription Access camera NSPhotoLibraryUsageDescription Library UIRequiresFullScreen

What does crash report say?

The App just quits as you can’t test in the simulator.

When I look into the package that is built by Xojo I can’t see any reference to “NSCameraUsageDescription” even though it is in the plist I dragged into the project.

Could that be the issue?

More likely it’s because the simulator doesn’t simulate the camera. Your code should check for this and not try to access the hardware.

Sorry I wasn’t clear. The App drops out when installed on a real test device.

[quote=390542:@Martin Fitzgibbons]When I look into the package that is built by Xojo I can’t see any reference to “NSCameraUsageDescription” even though it is in the plist I dragged into the project.

Could that be the issue?[/quote]
Yes. Apple specifically states that without these permission keys, your app will crash.

Here is the routine that I use. It will then request the authorization. The app will close after they authorize it. Then when you reopen the app it will be authorized. You must have Jason Kings IOSKIT for this to work.

[code]Dim iB as new iOSBlock(AddressOf AVFoundation.AVCaptureDevice.RequestAccessForMediaTypeCompletionHandler)

Select Case captureDevice.AuthorizationStatusForMediaType(AVFoundation.AVStringConstant(“AVMediaTypeVideo”))
Case AVFoundation.AVCaptureDevice.AVAuthorizationStatus.NotDetermined
captureDevice.RequestAccessForMediaTypeCompletionHandler(AVFoundation.AVStringConstant(“AVMediaTypeVideo”), iB)
Return True
Case AVFoundation.AVCaptureDevice.AVAuthorizationStatus.Restricted
Return False
Case AVFoundation.AVCaptureDevice.AVAuthorizationStatus.Authorized
Return True
Case AVFoundation.AVCaptureDevice.AVAuthorizationStatus.Denied
Return False
Else
Return False
End Select
[/code]

Thanks, that should work, still a bit puzzled by my error though.

I’m A step closer. I have the App correctly requesting access to use the camera through the plist entry but when you try and save the manipulated photo via the share panel the app quits

I have these 2 entries is something else needed

“NSPhotoLibraryUsageDescription” = “Allow the selection of photos from the photo library.”;
“NSCameraUsageDescription” = “Allow access to camera.”;

Martin try adding a value for Privacy - Photo Library Additions Usage Description. I have this in my app and can save photos. I believe this requirement was added in iOS10.

Thanks Jason that was the problem :slight_smile:

So to summarise we need the following for IOS10 plist

Privacy - Camera Usage Description
Privacy - Photo Library Usage Description
Privacy - Photo Library Additions Usage Description