Closed jocafi closed 3 years ago
Please, provide a sample app where the problem can be reproduced.
Here is the sample: https://github.com/jocafi/ionic5-test
The problem is you are trying to read the folder outside the promise result, so the read code is executed while the prompt is present and makes it return an error. It's a know issue https://github.com/ionic-team/capacitor-plugins/issues/320
But the workaround is simple, wait for the permissions result before trying to call other filesystem methods.
Move the code that "read the folder" inside the promise for Filesystem.requestPermissions(). The permission dialog will never be shown.
requestPermission resolves once the user accept or deny the prompt, so the code inside the requestPermission .then is executed. The permission dialog is shown by requestPermission, the problem in your app is the read folder code triggers another prompt, but as one is already shown it gets canceled, and by the issue I linked, the first promise gets rejected instead of the second one.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.
Bug Report
Plugin(s)
Capacitor Version
Platform(s)
Current Behavior
Expected Behavior
the app does not wait for the user allow or not the permission.
Code Reproduction
Other Technical Details
I am trying to use the Filesystem from Capacitor v. 3.0.0-rc.0, but the app fails to start, because I need to load a config file at the beginning and the app does not wait user input to allow or not the permission to READ and WRITE.
I am using a Samsung S20, Android 11. I added android:requestLegacyExternalStorage="true" to my tag in the AndroidManifest.xml file as described in the documentation.
I tried to use the plugin for android-permissions but I get an error:
In order to reproduce the error I had to uninstall and install the app again.
Additional Context