0

Description

I am using React-Native-Image-Picker to Select and Upload Files from my App, The issue i am facing that It is working in Android but in ios react-native-image-picker dialog automically closes after launching, therefore i cannot select files for upload. All the required permissions by ios for file upload have also been given.

 React-Native-image-picker dialog

How to repeat issue and example

import ImagePicker from 'react-native-image-picker';
import RNFetchBlob from 'react-native-fetch-blob';

var options = {
      title: 'Select Image',
      quality : 0.25,
      storageOptions: {
        skipBackup: true,
        path: 'images',
      },
    };
  ImagePicker.showImagePicker(options, response => {
      console.log('Response = ', response);

      RNFetchBlob.fs.stat(response.path)
      .then((stats) => {
        if (stats.size <= 5000000) {
          let source = response;
          let checkboxStates = {...this.state.checkboxStates}; 
          checkboxStates['image'] = true;

          this.setState({ imagePath: source, imageVisible: true, totalUploadSize: this.state.totalUploadSize + stats.size });   
          this.setState({checkboxStates});
        }
        else{
          toastMessage('Image should be less than 5 MB');
        }
      }).catch((err) => {});

    });

Additional Information

  • React Native version: 0.61.5
  • Platform: IOS
  • Development Operating System: Mac OS Mojave 10.14.2
  • Dev tools: Xcode 10.14.2
  • Device : IPad Pro (IOS 9)

2 Answers2

7

for someone who experience this, in my case this is cause of close of modal of choose option of image upload the open image picker immediately. try to close in given time then open image library or close modal after image picker launched like this :

ImagePicker.launchCamera(imageOptions, async (response) => {
          setModalPicker(false)
5

This happens when the modal that has the option buttons for selecting either from camera or gallery is closed. You can close the modal after selecting an image.

ImagePicker.launchImageLibrary(options, (response) => {
        //close the modal here
 })
Brianhenry
  • 195
  • 1
  • 8