fix: Fix photo not saving in example app on Android 13+ (#2522)

On Android 13+, requesting the WRITE_EXTERNAL_STORAGE permission
immediately denies, without asking the user. The @react-native-camera-roll/camera-roll
plugin being used already supports using scoped storage for saving
images on Android 13+, so this commit skips the permission check in that
case, since no permissions are needed.
This commit is contained in:
Menardi 2024-02-07 10:51:24 +00:00 committed by GitHub
parent 3192f5e939
commit a4e241a431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,8 @@ import { useIsFocused } from '@react-navigation/core'
import FastImage, { OnLoadEvent } from 'react-native-fast-image'
const requestSavePermission = async (): Promise<boolean> => {
if (Platform.OS !== 'android') return true
// On Android 13 and above, scoped storage is used instead and no permission is needed
if (Platform.OS !== 'android' || Platform.Version >= 33) return true
const permission = PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE
if (permission == null) return false