Working on a React Native project and facing some challenges, I find myself in need of requesting Video and Image permissions. Despite already including the users in the androidmanifest file,
I'm importing necessary modules from 'react-native' to handle permissions in my Bin component:
const requestCameraPermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES,
{
title: "Cool Photo App Camera Permission",
message:
"Cool Photo App needs access to your camera so you can take awesome pictures.",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the camera");
} else {
console.log("Camera permission denied");
}
} catch (err) {
console.warn(err);
}
};