Nitya Nitya - 28 days ago 19
Swift Question

Photo Library/Camera settings programmtically

I want to enable Camera/Photo library settings for my application. Can i show the alert to enable these programmatically
like when application starts. I have attached picture to show i want to see similar settings for my applicationenter image description here

for my application, i am not seeing this settings.

My problem is this application runs in Guided access mode and once user put the application in guided access modes,
application is not getting an iOS alerts , so the default alerts will not come and user will not be able to enable access to photo library.
i have keys description in plist file.

Is there any way i can enable these settings in beginning of application.

Answer

No. You can request access programmatically but the request pops up the alert and waits for the user to accept or deny access. There is no way to enable the access without the alert.

If this could be done then it would completely negate the whole point of the user having control over what an app can access or not.

Based on your comments below, you need to know how to programmatically request authorization so the alerts can be responded to.

Use AVCaptureDevice requestAccess(forMediaType:completionHandler:) request access to the camera.

Use PHPhotoLibrary requestAuthorization(_:) to request access to the photo library.

For a better UX, don't make the 2nd request until the 1st one is complete.