In order to fetch photo's creationDate, so use requestAuthorizationForAccessLevel before show PHPickerViewController.
PHAccessLevel level = PHAccessLevelReadWrite;
[PHPhotoLibrary requestAuthorizationForAccessLevel:level handler:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusLimited || status == PHAuthorizationStatusAuthorized) {
dispatch_async(dispatch_get_main_queue(), ^{
PHPickerConfiguration *configuration = [[PHPickerConfiguration alloc] initWithPhotoLibrary:[PHPhotoLibrary sharedPhotoLibrary]];
configuration.filter = [PHPickerFilter imagesFilter];
configuration.selectionLimit = 1;
PHPickerViewController *picker = [[PHPickerViewController alloc] initWithConfiguration:configuration];
picker.delegate = self;
[self showViewController:picker sender:nil];
});
}
}];
although status is .limited, but iOS 14 still display all images.
How can i get only limited photos with PHPickerViewController?
Open the iOS Shortcuts App and tap on the Automation button at the bottom of the app. To get some ideas for what can be done with iOS automations, browse through the following screenshots of iOS 14 actions.
You can opt to give apps only an approximate location lock. iOS 14 includes a couple of new ways that you can give apps certain permissions, but only up to a point. The idea is that there are some apps you trust a bit more than others in terms of looking at your photos or tracking where you are.
The iOS 14 Privacy and Security Features You Should Know 1 Know When Apps Use Your Camera and Mic. Apps on iOS have to explicitly ask for your permission to use the camera and microphone, and from iOS 14 onwards, you'll ... 2 Limit Access to Photos and Location. ... 3 Sniff Out Bad Passwords. ... 4 Discourage Wi-Fi Tracking. ...
How do I enable unknown sources in iOS? Head to Settings, then tap Security and toggle the Unknown sources switch to On … How do I enable unknown sources? Go to Settings & gt; Security. Check the option “Unknown sources”. Tap OK on the prompt message. Select “Trust”. Why can’t I install apps from unknown sources?
So a couple of things got changed in iOS 14, let's see step by step
1. How to read PHPhotoLibrary access permission status
Old
let status = PHPhotoLibrary.authorizationStatus()
New
let status = PHPhotoLibrary.authorizationStatus(for: .readWrite)
2. How to request PHPhotoLibrary access permission
Old
PHPhotoLibrary.requestAuthorization { status in
//your code
}
New
PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
switch status {
case .limited:
print("limited access granted")
default:
print("denied, .restricted ,.authorized")
}
}
It is your responsibility to show gallery like below sample code in case of user granted you limited permission
if status == .limited {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self)
}
When you presentLimitedLibraryPicker the selected images from the previous session would be already marked check, along with a message on top of screen- "Select more photos or deselect to remove access"
In-case the user granted you limited access still you present the normal gallery using UIImagePickerController or a third party library like BSImagePicker, a gallery with all pictures would be shown even you can select and import into your app but in Xcode 12 console it will show warnings as below
Failed to decode image
[ImageManager] Failed to get sandbox extension for url: file///filepath/5003.JPG, error: Error Domain=com.apple.photos.error Code=41008 "Invalid asset uuid for client" UserInfo={NSLocalizedDescription=Invalid asset uuid for client}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With