Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in saving image when "iCloud Photo Library" is "ON" in settings in iOS 11 #88

Open
leftdead7 opened this issue Oct 6, 2017 · 14 comments

Comments

@leftdead7
Copy link

Getting "Retrieved asset is nil" in failure callback when i am trying to save a image when "iCloud Photo Library" setting is turned ON . When i turn off the setting i am unable to save the image well.
The plugin was working really well till iOS 10.3 . Please suggest if i need to do any changes for "iCloud Photo Library"

@leftdead7
Copy link
Author

Sorry

The image is getting saved in the device, but still i am getting "Retrieved asset is nil" in error callback

I actually do not need the item back after saving the image to gallery, so can i safely ignore this error?

@jayordway
Copy link

I am seeing the same issue with iOS 11.

@bytestack
Copy link

Same here with iOS 11, disabled iCloud Photo Library and it works know

@mikewagz
Copy link

mikewagz commented Nov 8, 2017

Also seeing this.

@gildebrand
Copy link

I'm having this issue as well, and will do my best to be able to resolve it (even if I'm not very good at native development) 😅

This actually worked fine while iOS 11.0 was in beta (and maybe even the GM, but I'm not quite sure about that). I will have a look if there was any changes made to the Gallery API during the beta phase.

@nharrer
Copy link

nharrer commented Nov 13, 2017

Could it be a race condition somewhere? Because sometimes it works.
Also when the exception occurs, the image is not added to the album with the name given in saveImage().
But in either case the image shows up in "All Photos". (Tested on iOS 11.1.1)

@mubasshir
Copy link

@nharrer did you find any solution?

@nharrer
Copy link

nharrer commented Dec 16, 2017

@mubasshir no, unfortunately not. Thankfully it's not a complete show stopper, since the pictures show up in "All Photos". And I can also confirm that it starts working once iCloud Photo Library is turned off (which is not an option for my customers though).

@mubasshir
Copy link

I guess I will hardcode and display success message if this particular error occurs

@endani
Copy link

endani commented Feb 9, 2018

Hey guys,
Anyone could solve this? I don't have any more ideas or workarounds here :/

thanks!

@Saturnyn
Copy link

Saturnyn commented Apr 3, 2018

The issue is discussed here: https://stackoverflow.com/questions/26480526/alassetslibrary-assetforurl-always-returning-nil-for-photos-in-my-photo-stream

The comment by Thomas Hilbert seems to explain the bug in the plugin:

I've made the observation that trying to retrieve an asset using assetForURL inside a writeImage toSavedPhotosAlbum success block for that same asset will yield an asset of nil (most of the time).

However, retrieving the asset with assetForURL some time after the writeImage success block has completed execution does yield the correct asset.

I tried his solution and added a sleep(1) inside saveImage(), just before the self.putMediaToAlbum() call. It seems to fix the issue, at least for me.

This fix is not very clean: I doubt calling sleep() is a good practice, and the 1 second delay will probably be too much or too little depending on the context.
I don't have enough swift knowledge to write this, but it looks like an acceptable workaround would be to write a loop that calls asset() every 100ms until it returns something else than nil (with a timeout after a few unsuccessful calls).

@ghost
Copy link

ghost commented Jul 3, 2018

Issue is still present :(

@jasonz1987
Copy link

i make a pull request to resove this issue, see #141

@zhzhch335
Copy link

image
Just sleep it!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests