maitrungduc1410 / react-native-video-trim

Video trimmer for React Native App
MIT License
37 stars 14 forks source link

WRITE_EXTERNAL_STORAGE permission was not requested #17

Closed yanghun0070 closed 5 months ago

yanghun0070 commented 5 months ago

After updating compileSdk and targetSdk to 33, a problem occurred where WRITE_EXTERNAL_STORAGE permission was not requested when installing the app.

yanghun0070 commented 5 months ago

@maitrungduc1410

https://github.com/facebook/react-native/issues/36714

I think you can change the code below.

export async function showEditor(
  videoPath: string,
  config: EditorConfig = {}
): Promise<void> {
  const { maxDuration, saveToPhoto = true } = config;
  const outputPath = await VideoTrim.showEditor(videoPath, {
    saveToPhoto,
    maxDuration,
  });

  if (Platform.OS === 'android' && saveToPhoto) {
    if (Platform.Version < 33) {
      await VideoTrim.saveVideo(outputPath);
    } else {
      try {
        const granted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE!,
          {
            title: 'Video Trimmer Photos Access Required',
            message: 'Grant access to your Photos to write output Video',
            buttonNeutral: 'Ask Me Later',
            buttonNegative: 'Cancel',
            buttonPositive: 'OK',
          }
        );
        if (granted === PermissionsAndroid.RESULTS.GRANTED) {
          await VideoTrim.saveVideo(outputPath);
        } else {
          VideoTrim.hideDialog();
          throw new Error('Photos Library permission denied');
        }
      } catch (err) {
        throw err;
      }
    }
  }
}
maitrungduc1410 commented 5 months ago

Thanks for letting me know,

Yeah from sdk 33 we don't need to request for storage permission, will push a fix soon

maitrungduc1410 commented 5 months ago

please upgrade to 1.0.7, I fixed this, from Android >= 33, it won't request for this permission