Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2020 Privacy & SecuritySwiftUI & UI FrameworksPhotos & Camera

WWDC20 · 14 min · Privacy & Security / SwiftUI & UI Frameworks / Photos & Camera

Handle the Limited Photos Library in your app

Access the photos and videos you need for your app while preserving privacy. With the new Limited Photos Library feature, people can directly control which photos and videos an app can access to protect their private content. We’ll explore how this feature may affect your app, and take you through alternatives like PHPicker. Check out “Meet the New Photos Picker” to learn more about PHPicker and how this this fully private picker can help you avoid requiring full Photos Library access in your app.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 3 snippets

Query for authorization status swift · at 8:36 ↗
import Photos

let accessLevel: PHAccessLevel = .readWrite
let authorizationStatus = PHPhotoLibrary.authorizationStatus(for: accessLevel)

switch authorizationStatus {
case .limited:
    print("limited authorization granted")
default:
    //FIXME: Implement handling for all authorizationStatus values
    print("Not implemented")
}
Request read/write authorization swift · at 9:43 ↗
import Photos

let requiredAccessLevel: PHAccessLevel = .readWrite
PHPhotoLibrary.requestAuthorization(for: requiredAccessLevel) { authorizationStatus in
    switch authorizationStatus {
    case .limited:
        print("limited authorization granted")
    default:
        //FIXME: Implement handling for all authorizationStatus
        print("Unimplemented")
        
    }
}
Present the limited library management UI swift · at 12:04 ↗
import PhotosUI

let library = PHPhotoLibrary.shared()
let viewController = self

library.presentLimitedLibraryPicker(from: viewController)

Resources