Untitled
unknown
plain_text
2 years ago
2.3 kB
6
Indexable
//Read Media-Images permission
export const requestReadMediaPermission = async () => {
if (Platform.OS === 'ios') {
check(PERMISSIONS.IOS.MEDIA_LIBRARY)
.then(result => {
switch (result) {
case RESULTS.UNAVAILABLE:
// console.log(
// 'This feature is not available (on this device / in this context)',
// );
break;
case RESULTS.DENIED:
// console.log('The permission has not been requested / is denied but requestable');
request(PERMISSIONS.IOS.MEDIA_LIBRARY)
.then((result: PermissionStatus) => {
// console.log('ress', result);
})
.catch();
break;
case RESULTS.LIMITED:
// console.log('The permission is limited: some actions are possible');
break;
case RESULTS.GRANTED:
// console.log('The permission is granted');
break;
case RESULTS.BLOCKED:
// console.log('The permission is denied and not requestable anymore');
break;
}
})
.catch(error => {
// …
});
} else if (Platform.OS === 'android') {
check(PERMISSIONS.ANDROID.READ_MEDIA_IMAGES)
.then(result => {
switch (result) {
case RESULTS.UNAVAILABLE:
// console.log(
// 'This feature is not available (on this device / in this context)',
// );
break;
case RESULTS.DENIED:
// console.log('The permission has not been requested / is denied but requestable');
request(PERMISSIONS.ANDROID.READ_MEDIA_IMAGES)
.then((result: PermissionStatus) => {
console.log('ress', result);
})
.catch();
break;
case RESULTS.LIMITED:
// console.log('The permission is limited: some actions are possible');
break;
case RESULTS.GRANTED:
// console.log('The permission is granted');
break;
case RESULTS.BLOCKED:
// console.log('The permission is denied and not requestable anymore');
break;
}
})
.catch(error => {
// …
});
}
};Editor is loading...
Leave a Comment