iOS 14 Beta check PHAsset permissions for .limited access level

Viewed 1601

in iOS 14 beta, is there a way to check if the app has permissions to load a PHAsset image before trying to load it with PHImageManager.requestImage? This is for PHAuthorizationStatus.limited - when I fetch all assets in a PHAssetCollection, it returns those without permissions as well. I see an error object only when I try to load the image itself with PHImageManager.requestImage in the returned info object.

EDIT:

It turns out that this is a problem only on simulator. When I ran the app on a real device with iOS 14 beta, the PHAssetCollection fetch returned only those PHAssets that the user has granted access to.

2 Answers

Here are something I've tested on a real device:

You can have access to all the smart albums (in the form of PHAssetCollection) even if you are in Limited Photo Access mode. However, you can fetch assets from these collections only if a user has explicitly selected it. It's meaningless to have a collection without any assets available.

You can NOT have access to any user album in Limited Photo Access mode.

It behaves a little differently on a simulator as you can have access to all the albums, no matter it is user album or smart album in Limited Photo Access mode. And you can fetch assets from these collections without limitations. However, you cannot get any data from these assets if the user haven't selected it. I performed a requestImage operation on an asset which I haven't selected in the popup and it failed with domain error code: -1.

try to add a predicate with mediaType, then fetch the result

Related