Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Take picture, Expo client suddenly stopped #7

Open
jsmageto opened this issue Nov 10, 2017 · 4 comments
Open

Take picture, Expo client suddenly stopped #7

jsmageto opened this issue Nov 10, 2017 · 4 comments

Comments

@jsmageto
Copy link

Hi,

i'm facing problem, when i take picture, Expo client suddenly stopped without error information

snap = async function(){
if (this.camera) {
this.camera.takePictureAsync().then(data => {
FileSystem.moveAsync({
from: data,
to: ${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
Vibration.vibrate();
});
});
}
};

how to display the error message?

Thanks

@jsmageto
Copy link
Author

with this still can't show the error

try{
this.camera.takePictureAsync().then(data => {
FileSystem.moveAsync({
from: data,
to: ${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
//Vibration.vibrate();
});
});
}catch(error)
{
console.log('Error Take pic : '+error);
}

@mali3days
Copy link

mali3days commented Dec 4, 2017

Hi, i had the same problem.
FileSystem.moveAsync, change field "data" to "data.uri".
This change solved problem in my case.

To display error add .catch() after .then()

  this.camera.takePictureAsync()
    .then((data) => {
      FileSystem.moveAsync({
        from: data.uri,
        to: `${FileSystem.documentDirectory}photos/Photo_${this.state.photoId}.jpg`,
      }).then(() => {
        this.setState({
          photoId: this.state.photoId + 1,
        });
        Vibration.vibrate();
      })
        .catch((e) => {
          console.log(e, 'ERROR');
        });
    })
    .catch((e) => {
      console.log(e, 'takePicture ERROR');
    });

@NaveenDK
Copy link

NaveenDK commented Dec 5, 2017

Thanks For this Worked For me!

@samburgers
Copy link

@mali3days you should submit a pull request for this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants