dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
538 stars 359 forks source link

Storage permission Issue on Android after updating to API 33 #499

Closed JeetuChoudhary closed 11 months ago

JeetuChoudhary commented 1 year ago

Current behavior:

After updating the app to target Android API 33. When I try to download an image, it shows the Storage Request dialog stating to allow the app to access files on your device.

I have tried to request permission again for Android API 33 as you mentioned in the documentation and it doesn't open any permission dialog and shows following message in logs:

Requesting permission for android.permission.READ_EXTERNAL_STORAGE

Requesting permissions

Notifying listeners for event pause

No listeners found for event pause

App paused

Unable to find a Capacitor plugin to handle permission requestCode, trying Cordova plugins 0

Expected behavior:

It should download and store images on the phone after clicking on the download button.

Screenshots

wxs-screenshot

Environment information

Capacitor:

System:

Lakshman1996 commented 1 year ago

It is happening same to us after updating to 33. https://github.com/apache/cordova-plugin-file/issues/577 Also seems related

dpa99c commented 11 months ago

Android 13 / API 33 removes WRITE_EXTERNAL_STORAGE/READ_EXTERNAL_STORAGE permissions and replaces them with READ_MEDIA permissions (see here) So requesting EXTERNAL_STORAGE permission when build SDK >= 33 will have no effect. Instead request READ_MEDIA, e.g.

cordova.plugins.diagnostic.requestRuntimePermission(function(status){
    console.log("Permission: " + status);
}, function(error){
    console.error("The following error occurred: "+error);
}, cordova.plugins.diagnostic.permission.READ_MEDIA_IMAGES);