Permissions
Android Specific Permissions
In order to get Android's image drag and drop to work, you'll need to get media permission. You can do this by opening your project's AndroidManifest.xml
and add the following lines inside the <manifest>
tag:
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
Getting Permission
You can use react-native-permissions
or any other methods to get the permission. Here's an example using react-native-permissions
:
const useMediaPermission = () => {
useEffect(() => {
const fn = async () => {
try {
if (ANDROID_API_LEVEL >= 33) {
await requestMultiple([
PERMISSIONS_LIB.ANDROID.READ_MEDIA_IMAGES,
PERMISSIONS_LIB.ANDROID.READ_MEDIA_VIDEO,
]);
}
else {
await request(PERMISSIONS_LIB.ANDROID.READ_EXTERNAL_STORAGE);
}
} catch (_) {}
};
if (Platform.OS === "android") fn();
}, []);
};