I'm encountering an issue with MediaLibrary.requestPermissionsAsync() in an Android 11 emulator. Even when the user has already granted the requested permission, this function consistently asks for permission, resulting in an unwanted permission prompt.
I'm handling permissions as follows:
const perm = await MediaLibrary.getPermissionsAsync();
if (!perm.granted) {
const perm = await MediaLibrary.requestPermissionsAsync();
}
try {
const asset = await MediaLibrary.createAssetAsync(uri);
const album = await MediaLibrary.getAlbumAsync('Download');
if (album == null) {
await MediaLibrary.createAlbumAsync('Download', asset, false);
} else {
await MediaLibrary.addAssetsToAlbumAsync([asset], album, false);
}
} catch (e) {
handleError(e);
}
Expectation:
If the user has already granted the required permissions, MediaLibrary.requestPermissionsAsync() should not prompt for permission again. The app should proceed with the provided actions as permissions are already granted.
Actual:
Despite the user having granted permissions, MediaLibrary.requestPermissionsAsync() consistently asks for permission, leading to an unnecessary permission prompt.
What is the expo version? I'm exp 47, and the same thing happens again. After searching, it seems that upgrading to 48 will solve the problem. (I haven't tried it yet) please note.
https://github.com/expo/expo/issues/15273#issuecomment-1545943670