BSImagePicker icon indicating copy to clipboard operation
BSImagePicker copied to clipboard

BSImagePicker does not open on iOS 13.5.1

Open india2sarthak opened this issue 5 years ago • 6 comments

Hi,

I've been using the BSImagePicker library for some time now. Recently, one of my users reported that the picker simply does not show up for them. Here is how I am using the library.

Initializing the PickerController

let imagePicker = ImagePickerController()
func showImagePicker(sourceType _: UIImagePickerController.SourceType) {
       setImagePickerSettings()
       setImagePickerFetchResults()

       self.presentImagePicker(imagePicker, select: { asset in
           print("Selected: \(asset)")
       }, deselect: { asset in
           print("Deselected: \(asset)")
       }, cancel: { assets in
           print("Canceled with selections: \(assets)")
       }, finish: { assets in
           print("Images selection finalized finalized")
           self.handleSelectedImageAssets(assets: assets)
       }, completion: {})
   }

Configuring the picker controller

  private func setImagePickerSettings() {
        imagePicker.settings.selection.max = 10
        imagePicker.settings.theme.selectionStyle = .checked
        imagePicker.settings.fetch.assets.supportedMediaTypes = [.image]
        imagePicker.settings.selection.unselectOnReachingMax = true
        imagePicker.settings.theme.albumTitleAttributes = [
            NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14),
            NSAttributedString.Key.foregroundColor: UIColor.black,
        ]
    }

    private func setImagePickerFetchResults() {
        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
            ),
            PHAssetCollection.fetchAssetCollections(
                with: .smartAlbum,
                subtype: .smartAlbumFavorites,
                options: options
            ),
            PHAssetCollection.fetchAssetCollections(
                with: .smartAlbum,
                subtype: .smartAlbumSelfPortraits,
                options: options
            ),
            PHAssetCollection.fetchAssetCollections(
                with: .smartAlbum,
                subtype: .smartAlbumPanoramas,
                options: options
            ),
        ]
    }

BSImagePicker version: 3.2.1 iOS version: 13.5.1 iPhone: iPhone 11 Pro Max

Thanks a lot for helping :)

india2sarthak avatar Aug 26 '20 14:08 india2sarthak

Coincidence or not, one of my users reported yesterday that the picker was not returning images for him, and he’s on iOS 13.5.1 as well. It’s a different scenario and I’m checking other things here first, but I thought I’d share since it’s the same iOS version and I have no complaints from other users

alezoffoli avatar Aug 27 '20 11:08 alezoffoli

Haha. Do you see any issues with the code? That could possibly lead to the error

india2sarthak avatar Aug 27 '20 11:08 india2sarthak

Getting the blank white screen in iOS 14.0 when presenting picker.

NirajCapermint avatar Oct 23 '20 11:10 NirajCapermint

same here one of our QA engineer reported about it, is it just 13.5.1 or all 13.x versions

kodekarim avatar Nov 06 '20 04:11 kodekarim

We decided to switch to the native iOS https://developer.apple.com/documentation/photokit/phpickerviewcontroller PHPickerViewController for devices running iOS 14 and above :( @mikaoj any updates on this? The library works great otherwise

india2sarthak avatar Nov 06 '20 07:11 india2sarthak

    public func presentImagePicker(_ imagePicker: ImagePickerController, animated: Bool = true, select: ((_ asset: PHAsset) -> Void)?, deselect: ((_ asset: PHAsset) -> Void)?, cancel: (([PHAsset]) -> Void)?, finish: (([PHAsset]) -> Void)?, completion: (() -> Void)? = nil) {
        // Check if authorized
        authorize {
            /* .... do some stuff when authorized and then present the picker */
            self.present(imagePicker, animated: animated, completion: completion)
        }
    }

    private func authorize(_ authorized: @escaping () -> Void) {
        PHPhotoLibrary.requestAuthorization { (status) in
            switch status {
            case .authorized:
                DispatchQueue.main.async(execute: authorized)
            default:
                // Not authorized isn't handled. You need to handle this in your app and probably show some
                // message/view explaining why/how to authorize the app to use the photo library
                break
            }
        }
    }

My only explanation would be that you don't have been authorized to access the users photo library

mikaoj avatar Nov 06 '20 07:11 mikaoj

Hey, thanks for your reply. I am checking for the permissions, before trying to open BSImagePicker. Could this be due to some other reason, have you been able to reproduce it on iOS 13.51?

india2sarthak avatar Nov 07 '20 10:11 india2sarthak