DragonCherry / AssetsPickerViewController

Powerfully Customizable - Multiple Photo & Video Picker Controller
MIT License
388 stars 136 forks source link

Synchronize Photos on iOS 14 #87

Closed walrus-operator closed 4 years ago

walrus-operator commented 4 years ago

Hi there,

First of all, thank you for creating this fantastic library! I searched through the issues but didn't see this reported as of yet. Right now on XCode 12.0 Beta 5 and iOS 14.0 Beta, the user will be prompted with a permissions alert with the following options: Select Photos, Allow Access to All Photos, or Don't Allow.

image

If the user chooses "Select Photos" and chooses to either add (or remove) access to their photos, the AssetsPickerViewController does not synchronize the changes even when it is closed completely (deallocated) and relaunched. If the user did not grant access to certain PHAssets they still appear in the collectionView as default cells which leads me to believe that the collectionView data source is not being synchronized properly.

image

Is this a known bug?

Thanks!

brunnobraga commented 4 years ago

Any idea of what's going on here? iOS 14 release has been announced for tomorrow.. would like to get rid of this.

DragonCherry commented 4 years ago

I've fixed a bug to avoid assigning empty image that occasionally returned by asset manager and to retry reqeust fetch image again in such case. Please try this on 2.9.4

brunnobraga commented 4 years ago

Thank you for your support.

I've just tested on 2.9.5 and I still see a scenario where the assets are not refreshed. The simulator does not yield the same results, you have to use a physical device to reproduce: Basic Usage -> Pick -> Select Photos... (on iOS 14 new prompt) -> Select a couple of pics -> Done -> Kill the app (in order to force a new lifecycle)

Run again -> Basic Usage -> Pick -> Select More Photos (iOS 14 prompt). Here there are 2 branches

  1. Select more pics -> Done. The new ones will not show up on the picker.
  2. Unselect previously selected pics -> Done. The unselected ones will still show up.

If you cancel the picker and come back it will be updated. Same if you try to select a different album or reselect the current one. It's just the one case where you use the new Select More Photos prompt, which only appears once per lifecycle.

DragonCherry commented 4 years ago

@brunnobraga I'm sorry to confuse you. I didn't fully understand this and I've fixed regardless bugs at first. From v2.9.6 it refreshes it's photo list when it notified limited authorization status.

robertofrontado commented 3 years ago

I'm using 2.9.7 and to me, it always crashes in the simulator (using iPhone 12 Pro - 14.2) :/

open func fetchAssets(isRefetch: Bool = false, completion: ((PHFetchResult<PHAsset>?) -> Void)? = nil) {

        fetchAlbums(isRefetch: isRefetch, completion: { [weak self] _ in

            guard let `self` = self else { return }
            if isRefetch {
                self.fetchResult = nil
            }

            // set default album
            self.selectAsync(album: self.defaultAlbum ?? self.cameraRollAlbum) { successful, result in <---- IN THIS LINE
                completion?(result)
            }
        })

    }

defaultAlbum & cameraRollAlbum are nil

giannigdev commented 1 year ago

Thank you for your support.

I've just tested on 2.9.5 and I still see a scenario where the assets are not refreshed. The simulator does not yield the same results, you have to use a physical device to reproduce: Basic Usage -> Pick -> Select Photos... (on iOS 14 new prompt) -> Select a couple of pics -> Done -> Kill the app (in order to force a new lifecycle)

Run again -> Basic Usage -> Pick -> Select More Photos (iOS 14 prompt). Here there are 2 branches

1. Select more pics -> Done. The new ones will not show up on the picker.

2. Unselect previously selected pics -> Done. The unselected ones will still show up.

If you cancel the picker and come back it will be updated. Same if you try to select a different album or reselect the current one. It's just the one case where you use the new Select More Photos prompt, which only appears once per lifecycle.

Hi, are you still experiencing the same issue of collection view list of items not refreshing immediately after selecting more images from the popup form and the popup form being disploayed only one time during the whole App life cycle unless we kill and restart the app or we remove and add the library authorization?

Thanks in advamce for your feedback ;)

giannigdev commented 1 year ago

I've fixed a bug to avoid assigning empty image that occasionally returned by asset manager and to retry reqeust fetch image again in such case. Please try this on 2.9.4

Hi, in the current project i am working, on previous devs have made severals updates to this library that the last version i have is the 2.5.7 and could not update it to the latest versione you mentioned. I need to update the collection view data immediately after the user selects more videos/images from the library so that we can see the new items added in the collection view which currently happens only when the user goes back and re enters the AssetsPhotoViewController object. Can you point me to the commit where did you add in the 2.9.4/2.9.6 tags versions such behaviors specifically the delegate method that will be called after we have pressed the Done button present on the right corner of the UIImagePickerViewController?

Thanks in advance for your time