Skip to content

Commit

Permalink
fix: Fix photo not saving in example app on Android 13+ (mrousavy#2522)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Menardi authored Feb 7, 2024
1 parent 904b3d5 commit 7b32421
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package/example/src/MediaPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7b32421

Please sign in to comment.