User opens camera then goes back. After that, they can re-open the camera later.
User opens camera then goes back. Every attempt to open the camera after that returns a promise rejection indicating that the user cancelled.
Do something that uses openCamera
Hit 'Back'
Try to do openCamera again. It will return a promise rejection indication cancellation again.
Love react-native-image-crop-picker? Please consider supporting our collective:
馃憠 https://opencollective.com/react-native-image-crop-picker/donate
I have the error like this:
when I open imagePicker to pick image but cancel it, I get an error that say:
"Unhandled promise rejection"
version:
react-native: 0.54.4
react-native-image-crop-picker: 0.19.2
platform:
iPhone 6 - iOS 11.2 (emulator)
+1
same as @bodaghialib4 on :
"react-native": "0.55.4",
"react-native-image-crop-picker": "^0.21.1",
Android 8.1
Additional Info:
So the Message "Error: User cancelled image selection" from Image-Crop is send. So what's the right way to catch it?

Has this been solved ?
I used try/catch to solve this error.
bodaghialib4, could you be more specific? I'm not sure how catching an error would prevent the camera from returning a rejection and so not opening.
My code is something like this:
async _setImage() {
try {
//pick image information
let img = await ImagePicker.openPicker({
width: 200,
height: 200,
cropping: true,
});
console.log("image path: " + img.path.toString());
} catch (err) {
console.warn("error in setImage : " + err.toString());
}
}
My error occur only when User cancelled image selection and I ignore this error.
@bodaghialib4 catch just avoid runtime error! the main problem is still remain
I have the same issue in android 4.2.2
when i call pickImage i get this in logs:
(no crash cause of catch but still not working
err pickWithCamera: Error: User cancelled image selection
at createErrorFromErrorData (NativeModules.js:123)
at NativeModules.js:80
at MessageQueue.__invokeCallback (MessageQueue.js:346)
at MessageQueue.js:132
at MessageQueue.__guard (MessageQueue.js:262)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:131)
at debuggerWorker.js:72
pCamera = async () => {
await ImagePicker.openCamera({
cropping: true,
width: 400,
height: 400,
cropperCircleOverlay: true,
includeBase64: true,
compressImageQuality: 0.5,
}).then(image => {
console.log('received image', image);
}).catch(e => {
console.log('err pickWithCamera: ', e);
});
md5-6524c2dacfcb996e73eac9bcc8e5f3a5
"react-native-image-crop-picker": "^0.21.2",
"react-native": "0.51.0",
this problem solved after i change android:launchMode="singleInstance" to singleTop in activity tag at androidManifest file but however i really dont know what are the differences between this two lunchMode in reactNative!!
this problem solved after i change
android:launchMode="singleInstance"tosingleTopin activity tag at androidManifest file but however i really dont know what are the differences between this two lunchMode in reactNative!!
It's useful for me on Android 4.4.2, but my partner had change launchMode to singleInstance for some reason...
Most helpful comment
@bodaghialib4 catch just avoid runtime error! the main problem is still remain
I have the same issue in android 4.2.2
when i call pickImage i get this in logs:
(no crash cause of catch but still not working