How to use PHAuthorizationStatusLimited in iOS 14

As per Apple documentation here in this link : https://developer.apple.com/documentation/photokit/phauthorizationstatus?language=objc, in iOS 14+ one enumeration case i.e. “PHAuthorizationStatusLimited” has been added in PHAuthorizationStatus class to provide limited accessing photos from Gallery.

I have installed iOS 14 beta in my device and used Xcode 12 beta and macOS 11.0 beta to use this API, I am getting all photos even if I select limited photos to select initially. How do I implement this?

Also, this API is available with Xcode 12 beta and not on Xcode 11.5 (up to date version) as we can not upload the build with beta Xcode versions, how will I keep my app up to date before iOS 14 public release?

Replies

Hello,

I had a similar problem. I prepared my app for iOS. I make my check for access to photo library als follow:

Code Block objective-c
    switch ([PHPhotoLibrary authorizationStatus]) {
        case PHAuthorizationStatusNotDetermined: {
            NSLog(@"----> Not Determined <----");
            [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus statusNew) {
                switch (statusNew) {
                    case PHAuthorizationStatusDenied:
                        NSLog(@"----> Denied after Request <----");
                        break;
                    case PHAuthorizationStatusLimited:
                        NSLog(@"----> Limited after Request <----");
                        break;
                    case PHAuthorizationStatusAuthorized:
                        NSLog(@"----> Authorized after Request <----");
                        break;
                    case PHAuthorizationStatusRestricted:
                        NSLog(@"----> Restricted after Request <----");
                        break;
                    default:
                        break;
                }
            }];
            break;
        }
        case PHAuthorizationStatusDenied:
            NSLog(@"----> Denied <----");
            break;
        case PHAuthorizationStatusLimited:
            NSLog(@"----> Limited <----");
            break;
        case PHAuthorizationStatusAuthorized:
            NSLog(@"----> Authorized <----");
            break;
        case PHAuthorizationStatusRestricted:
            NSLog(@"----> Restricted <----");
            break;
        default:
        break;
}

If I select choose photos I only get the PHAuthorizationStatusAuthorized and not PHAuthorizationStatusLimited. Is there a bug in this api or what I do wrong ?
+[PHPhotoLibrary authorizationStatus] has been deprecated and was replaced with +authorizationStatusForAccessLevel:.
For backwards compatibility it will return PHAuthorizationStatusAuthorized if the user has chosen limited photo library access.
我也遇到了这样的问题改成了 authorizationStatusForAccessLevel: 拿到了limited状态 访问到的还是整个照片库 ,是什么原因那?
I also get all photos even if I select limited photos to select initially……
@MODWorld You are using the old, deprecated function which never returns PHAuthorizationStatusLimited - it returns PHAuthorizationStatusAuthorized even if the user only gave limited access, for backward compatibility. You need to use the new +requestAuthorizationForAccessLevel:handler: method.