Giter VIP home page Giter VIP logo

Comments (17)

viskin avatar viskin commented on August 27, 2024

Do you have this issue on iOS only, or also on Android?

from cordova-plugin-photo-library.

endoplasmic avatar endoplasmic commented on August 27, 2024

You could always just use this permissions plugin if you are stuck on time: https://github.com/NeoLSN/cordova-plugin-android-permission

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

I could not reproduce this on iOS and Android.
The plugin in my app never asks for permission by itself. Call to plugin just fails with error when no permission granted. As I catch the error, I show a dialog to user about the need to authorize access. The dialog calls requestAuthorization method, which opens app setting on iOS or shows system permission dialog on Android.
There should be no request for permission when an app starts.
Can it be other plugin that causes such an behavior in your case?

from cordova-plugin-photo-library.

Menardi avatar Menardi commented on August 27, 2024

I am only seeing this behaviour on iOS, not on Android.

I have looked into it a bit more, and have found that it only happens when cordova-plugin-file is installed. Interestingly, removing either cordova-plugin-file OR cordova-plugin-photo-library causes the prompt not to happen on start up.

In addition, I've found that PhotoLibraryService.requestAuthorization is not what is bringing up this prompt. I added a print statement to it and it wasn't logged on startup.

Funnily, I'm only using cordova-plugin-file so I can use this plugin! I need it to get the app's file:// url so I can save images from the www/ folder to Photos.

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

Weird. I use both cordova-plugin-file and cordova-plugin-photo-library, and there's no prompt on start up.
What versions do you use

  • of cordova
  • of cordova-ios
  • of other plugins (cordova plugin list)

from cordova-plugin-photo-library.

Menardi avatar Menardi commented on August 27, 2024

I managed to reproduce this with just these plugins:
cordova-plugin-add-swift-support 1.6.0 "AddSwiftSupport"
cordova-plugin-photo-library 1.1.6 "Photo Library"
cordova-plugin-file 4.3.0 "File"

I'm building with [email protected] and [email protected]. As far as I know, these are the most recent versions of everything as most were added this week.

One thing I am unsure about is, does the app explicitly have to show this dialog, or are there some calls that would automatically trigger it? I'm wondering where I should be looking for the possible cause of this dialog.

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

It would be great if you will isolate the problem to empty cordova project, that just opens permission prompt on start. Then please send me one on mail, and I'll have a look.
Are we talking about iOS10 device? What device?

from cordova-plugin-photo-library.

Menardi avatar Menardi commented on August 27, 2024

It happens on both an iPod Touch running iOS 9 and iPad Pro running iOS 10.

I have reproduced it in a blank project:

  • cordova create perm-test-photo-lib
  • cd perm-test-photo-lib
  • cordova platform add ios
  • cordova plugin add cordova-plugin-photo-library --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="To choose photos" --save
  • cordova plugin add cordova-plugin-file --save
  • cordova build ios
  • Open project in Xcode and run from there

If you cannot reproduce this way, I'll zip up that project and email it to the address on your profile.

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

Yep this reproduces the bug. I'll try to debug it...

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

You were right, it seems touching PHCachingImageManager at init caused prompt to appear.
Please try 1.1.7. I postpone initialization of PhotoLibraryService from plugin load to first api call.

from cordova-plugin-photo-library.

Menardi avatar Menardi commented on August 27, 2024

Thanks for such a quick fix! This does indeed stop the permission prompt from appearing on startup.

However, now that the permission prompt happens when I call saveImage, I have somewhat unusual behaviour. On first calling saveImage, the permission prompt shows as expected. This immediately causes the error handler to be fired, where my JS sees that the user has not yet given permission. However, once they do give permission, the success handler is then fired. So, my app ends up in a bit of an unusual state, as one call caused both failure and success!

I tried wrapping the call in requestAuthorization, but it doesn't work quite as expected. Even if the user has already granted permission, it will take them to the permissions screen. I was expecting it to immediately call the success callback if it had already been granted. What do you think?

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

Hmmm, I will try to reproduce this tomorrow. It's more intuitive to not get either handler called until the user responses to the prompt.

from cordova-plugin-photo-library.

Nuajan avatar Nuajan commented on August 27, 2024

I can also confirm this behaviour, been prompted for permission on app start, using file plugin as well, only on IOS, tested on an iPhone 6 10.1.1
I would be nice to be asked only when required but it think is not a critical thing.

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

I don't like current behavior when on iOS when prompt appears by itselft on API call, say on save.
I think it will be a good approach to add a check for PHPhotoLibrary.authorizationStatus() on each API call, and if set to notDetermined, to throw Permission error. Then user will call to requestAuthorization, which will display an alert.
I will add this ASAP.

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

Well, 1.1.10 now handles iOS permission with much more care. API call and requestAuthorization behave intuitively if permission not granted. API calls return Permission error, and requestAuthorization opens permission prompt (on first attempt) or redirects to app settings page (on subsequent calls).

from cordova-plugin-photo-library.

Menardi avatar Menardi commented on August 27, 2024

That sounds like the right behaviour. Thanks for being so responsive and fixing it so quickly. Definitely the best experience I've had reporting an issue on Github!

from cordova-plugin-photo-library.

viskin avatar viskin commented on August 27, 2024

Thank you, it's good to hear.

from cordova-plugin-photo-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.