negativetwelve / react-native-ux-cam

React Native wrapper for uxcam.com
53 stars 36 forks source link

allowShortBreakForAnotherApp breaks image picker #114

Closed matthias-pichler closed 3 years ago

matthias-pichler commented 4 years ago

if I call Uxcam.allowShortBreakForAnotherApp(true) before opening an image picker ( using react-native-image-crop-picker ) and calling Uxcam.resumeShortBreakForAnotherApp() in the finally block the app becomes unresponsive after closing the picker.

Below is the code that reproduces the problem.

try {
  Uxcam.allowShortBreakForAnotherApp(true);
  const { path } = (await ImagePicker.openPicker({
    multiple: false
  })) as Image;
  this.setState({
    imageURI: path,
    isFromGallery: true
  });
} catch (err) {
  logger.error(err);
} finally {
  Uxcam.resumeShortBreakForAnotherApp();
}

Tested on real Android device running Android v9 and using library version: 5.1.13

susanuxcam commented 4 years ago

Hey @warrify! I've just asked our engineering team to check it out. We will come back to you as soon as we have any news!

susanuxcam commented 4 years ago

Hi again @warrify! Does it work without the resumeShortBreakForAnotherApp? That isn’t needed here - you are just launching another component inside the app. ResumeShortBreak is for when you are going out to a different app - i.e. using Facebook app to confirm login - and will be away from your app for a few seconds but don’t want it split into two sessions. Please, let me know if it's clear!

matthias-pichler commented 4 years ago

I tried it without the resume but it still breaks :/

susanuxcam commented 4 years ago

Hey @warrify, we've just fixed the issue! You can update your plugin to the 5.1.14 version and let us know if everything works correctly now :)

susanuxcam commented 4 years ago

@warrify just one more thing:

Here is the working code snippet which might help you. We have tested this with the same library you mentioned.

pickSingle(cropit, circular=false, mediaType) { RNUxcam.allowShortBreakForAnotherApp(true); ImagePicker.openPicker({ width: 500, height: 500, cropping: cropit, cropperCircleOverlay: circular, compressImageMaxWidth: 1000, compressImageMaxHeight: 1000, compressImageQuality: 1, compressVideoPreset: 'MediumQuality', includeExif: true, }).then(image => { console.log('received image', image); RNUxcam.allowShortBreakForAnotherApp(false); this.setState({ image: {uri: image.path, width: image.width, height: image.height, mime: image.mime}, images: null }); }).catch(e => { RNUxcam.allowShortBreakForAnotherApp(false); console.log(e); Alert.alert(e.message ? e.message : e); }); }