Comments (17)
Do you have this issue on iOS only, or also on Android?
from cordova-plugin-photo-library.
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.
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.
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.
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.
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.
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.
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.
Yep this reproduces the bug. I'll try to debug it...
from cordova-plugin-photo-library.
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.
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.
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.
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.
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.
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.
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.
Thank you, it's good to hear.
from cordova-plugin-photo-library.
Related Issues (20)
- ERROR: Method 'requestAuthorization:' not defined in Plugin 'PhotoLibrary'
- Get photo library on ios 13.2.*+
- Success never shows up when no photos in library
- Complier Error
- undeclared type 'CDVURLProtocol' HOT 2
- how can i save a image with base64
- android 10 support (SDK 29) - get error when saving an image HOT 2
- Dependecy cordova-plugin-add-swift-support version="^2.0.2" is not working. UPDATE for earlier swift versions. HOT 1
- Using “requireCordovaModule” to load non-cordova module “glob” is not supported HOT 4
- Using “requireCordovaModule” to load non-cordova module “glob” is not supported HOT 1
- Getting "open failed: EACCES permission denied" even I have permissions. Android 10 HOT 4
- Can't build in IOS xcode HOT 6
- saveVideo ios 10+ 保存失败? HOT 1
- android 11 support (SDK 30) - get error when saving an image HOT 7
- Way to cancel getLibrary process? HOT 1
- i am not able to access specific album library based of id of album?any you help me
- Issue in Android 11 SDK 30 HOT 2
- img src = cdvphotolibrary://... err_unknown_url_scheme && android sdk > 30
- On Android 12, use the cordova.plugins.photoLibrary.saveImage method to save the image and then the APP will flash back HOT 3
- BSF Cordova Ecosystem Crowdfunding Plan
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-photo-library.