Checking for Photo Library access on iOS

Hello! I’m new to Corona and working on my first project, an art app that will be saving the end result to the user’s photo library. I have that working exactly how I like it using “display.capture”. However, prior to saving the image I’d like to check to make sure the user has enabled access to save photos to the photo library, and for the life of me I can’t figure out a way to do that.

I’m developing for iOS only and have tested the following on my iPad Air (running iOS 11) and iPhone SE (running iOS 12). I’m running the latest Corona daily build (2018.3407)

From what I’ve read in the documentation, this should (theoretically) do what I need it to:

local hasAccessToPhotos, hasPhotos = media.hasSource( media.PhotoLibrary ) if (hasAccessToPhotos == true) then -- save the image to the photo library else -- user has disabled access to the photo library, ask them to turn it on end

I expected that “hasAccessToPhotos” would be true only if the user has granted permission for the app to access the photo library, and would return “false” if photo library access was disabled. In all of my tests, “hasAccessToPhotos” is returning true, even when I go into the iOS settings screen and disable it.

I’ve had a lot of coffee today trying to figure this out and no luck - I’m guessing either I misunderstood what media.hasSource is supposed to do, or there is a bug of some kind, or I’ve just been staring at a screen for too long and nothing makes sense anymore :slight_smile: Would greatly appreciate any help! Thanks :slight_smile:

Just bumping this again, curious if anyone has any ideas I should try. Thanks!

Just bumping this again, curious if anyone has any ideas I should try. Thanks!

I had the same problem, i’ve tried PhotoLibrary and SavedPhotosAlbum, all return true when denied. Do you have solution now?

I researched one month ago

The runtime source code does not handle an error when saving an image to PhotosAlbum

UIImageWriteToSavedPhotosAlbum( image, nil, nil, nil )

The callback (delegate) function is nil so it does not tell us it is failed or not.