0
votes

For the first time picker opens gallery - all is ok. For the second time and other next times picker opens gallery and closes it right away. If I try use Camera - same result. Problem on device and simulator.

NSCameraUsageDescription, NSPhotoLibraryUsageDescription, NSMicrophoneUsageDescription are added to info.plist.

No any error in xcode, simulator and logs. App doesn't crash.

react-native: 0.62.2 react-native-image-crop-picker: 0.35.2

2

2 Answers

1
votes

The problem was in modal, that prefers to open camera or gallery, I close modal before calling Picker- that makes issue on iOS only, android - ok. Then I close modal after calling Picker and receiving file object - iOS works ok. I use this issue https://github.com/ivpusic/react-native-image-crop-picker/issues/1433

My final code:

    ImagePicker.openCamera({
        width: 300,
        height: 400,
        cropping: true,
    })
        .then(fileObj => {
            this.setState({
                isPhotoChoiceModalOpen: false,
            });
            return uploadImage(fileObj, user);
        })
0
votes

I had the same problem, I fixed it by adding a setTimeout of 100 ms.

 setTimeout(() => {
    ImagePicker.openPicker({
      width: 300,
      height: 400,
    })
      .then((image) => { ...})),100)


I think gallery and camera in ios uses some animation which causes this issue. Also note that if u are using any modal open/close operation with animation during gallery/camera open, that may also cause this issue.