Skip to content

Photos Permissions

levching edited this page Apr 15, 2020 · 4 revisions

Make sure that Photo Kit is enabled, before using this API.

Accessing the Photos library always requires explicit permission from the user. Your app’s info.plist file must provide a value for the NSPhotoLibraryUsageDescription key that explains to the user why your app is requesting Photos access. Apps linked on or after iOS 10.0 will crash if this key is not present. After the user grants permission, the system remembers the choice for future use in your app, but the user can change this choice at any time using the Settings app. If the user has denied your app photo library access, not yet responded to the permission prompt, or cannot grant access due to restrictions.

The following code snippet requests the user’s photo library permission.

using SA.iOS.Photos;
...
ISN_PHPhotoLibrary.RequestAuthorization((status) => {
    if(status == ISN_PHAuthorizationStatus.Authorized) {
        Debug.Log("Permission granted");
    } else {
        Debug.Log("Permission denied");
    }
});

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

using SA.iOS.Photos;
...
ISN_PHAuthorizationStatus status;
status = ISN_PHPhotoLibrary.AuthorizationStatus;
Debug.Log("Photo Library Authorization Status: " + status);

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

PhotosPermissions

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