Skip to content

Camera Permission

levching edited this page Apr 15, 2020 · 4 revisions

Camera usage always requires explicit permission from the user. Your app must provide an explanation for its use of capture devices using the NSCameraUsageDescription Info.plist key. iOS displays this explanation when initially asking the user for permission, and thereafter in the Settings app. Calling this method or attempting to start a capture session without a usage description raises an exception.

The following code snippet requests the user’s camera permission.

using SA.iOS.AVFoundation;
...
ISN_AVCaptureDevice.RequestAccess(ISN_AVMediaType.Video, (status) => {
if(status == ISN_AVAuthorizationStatus.Authorized) {
    Debug.Log("user has granted camera permission");
} else {
    Debug.Log("uAVMediaType.Video Permission declined");
}
});

You can always check current authorization status as shown on a snippet below:

using SA.iOS.AVFoundation;
...

ISN_AVAuthorizationStatus status;
status = ISN_AVCaptureDevice.GetAuthorizationStatus(ISN_AVMediaType.Video);
Debug.Log("Camera Authorization Status: " + status);

The NSCameraUsageDescription canbe provided with the IOS Native Settings editor. See the picture below:

CameraPermission

About

Foundation

AV Foundation

App Tracking Transparency

Game Kit

Store Kit

UI Kit

Social

Replay Kit

Contacts

AVKit

Photos

App Delegate

User Notifications

MediaPlayer

Core Location

AdSupport

EventKit

CloudKit

Authentication Services

XCode

Knowledge Base

Clone this wiki locally