BSImagePicker
BSImagePicker copied to clipboard
Images not shown first time after getting permission iOS 14
I'm using this library on iOS 14 and when I install my app the first time and allow permission to access all photos then there is no image in the picker. after cancel when again press the upload button and I got all pictures.
this is my code to present the image picker.
let imagePicker = ImagePickerController() imagePicker.settings.fetch.assets.supportedMediaTypes = [.image] imagePicker.settings.selection.max = 5 imagePicker.settings.theme.selectionStyle = .numbered imagePicker.settings.selection.unselectOnReachingMax = false let options = imagePicker.settings.fetch.album.options imagePicker.settings.fetch.album.fetchResults = [ PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: options), PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumRegular, options: options), ]
I am facing the same problem, did you find a solution?
Does it work if you don't set a custom fetch result?
Same problem faced here and I have not used any custom fetch results
Getting - _BSMachError: port 6c03; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND" - in console
Also getting this same problem
func photoAuthorization(authorized: @escaping () -> Void, unauthorized: @escaping () -> Void) { PHPhotoLibrary.requestAuthorization { (status) in switch status { case .authorized: DispatchQueue.main.async(execute: authorized) default: DispatchQueue.main.async(execute: unauthorized) } } }
and user thsi as
UIHelper.sharedInstance.photoAuthorization { self.setupImagePicker() } unauthorized: { SVProgressHUD.dismiss() self.showAlertViewSettings() }
I solved this issue on my application by wrapping the function that presents the ImagePickerController in a wrapper function that asks the user for authorization prior to presenting the picker:
PHPhotoLibrary.requestAuthorization { (auth_status) in
if auth_status == .denied || auth_status == .notDetermined {
/* User denied permission or left the authorization in an undetermined state
Enter code here to handle this event or leave it blank if you don't want to do anything
*/
} else {
/*
auth_status is either authorized, limited, or restricted. Call wrapper function
*/
self.FunctionThatPresentsImagePickerController()
}
}
However in iOS 14 when the PHAuthorizationStatus
is limited
the prompt will never re-appear, leaving users to only select the initial images they selected and nothing else. Upon further investigation I found that this is intended behavior on Apple's end- they only prompt to ask you to select more images once per app session. Odd design but that's how it works right now.
This solution is an anti-pattern and only really serves as a temporary solution until a fix is made.
The issue was because of the authorisation status
I solved this issue on my application by wrapping the function that presents the ImagePickerController in a wrapper function that asks the user for authorization prior to presenting the picker:
PHPhotoLibrary.requestAuthorization { (auth_status) in if auth_status == .denied || auth_status == .notDetermined { /* User denied permission or left the authorization in an undetermined state Enter code here to handle this event or leave it blank if you don't want to do anything */ } else { /* auth_status is either authorized, limited, or restricted. Call wrapper function */ self.FunctionThatPresentsImagePickerController() } }
However in iOS 14 when the
PHAuthorizationStatus
islimited
the prompt will never re-appear, leaving users to only select the initial images they selected and nothing else. Upon further investigation I found that this is intended behavior on Apple's end- they only prompt to ask you to select more images once per app session. Odd design but that's how it works right now.This solution is an anti-pattern and only really serves as a temporary solution until a fix is made.
The was the solution for my case as well. However instead of checking the status I manually asked for premission using the PHPhotoLibrary.requestAuthorization
and in the callback I presented the ImagePicker
using the UIViewController's present
method instead of presentImagePicker()
provided by the library.
EG:
PHPhotoLibrary.requestAuthorization {
(status) in
switch status {
case .authorized:
self.present(imagePicker, animated: true)
case .denied:
// Handle the denied logic
default:
break
}
}