I am trying simple task to open the gallery via btn click. If gallery permissions are not given to application it should prompt the user to enable them else gallery should be opened.
I am trying to check the gallery permission before opening the gallery using requestPermission() Camera Plugin. Here is sample code
const openGallery = () => {
debugger;
Camera.requestPermissions({ permission: ["photos"] })
.then((permission) => {
console.log("photo permission");
console.log(permission.photos);
})
.catch((err) => {
console.log(err);
});
Camera.requestPermissions()
.then((permission) => {
console.log("All permission");
console.log(permission.photos);
console.log(permission.camera);
})
.catch((err) => {
console.log(err);
});
};
I’ve tried calling Camera.requestPermission() method in both ways(with passing “photos” prop and without it). In android logcat I can see camera permission is denied but gallery permission is enabled even though in app settings both the permissions are denied.
Here is my android manifest file showing permissions required.
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- For Android 12 and below -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- For Android 13+ -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
Logcat output: