takePicture.js 443 B

12345678910111213
  1. import * as ImagePicker from 'expo-image-picker'
  2. function takePictureWithExpo () {
  3. return ImagePicker.getCameraPermissionsAsync()
  4. .then(({ granted }) => (granted
  5. ? ImagePicker.launchCameraAsync({ allowsEditing: true })
  6. : Promise.reject(new Error('Permissions denied'))))
  7. .then((result) => (!result.cancelled
  8. ? result
  9. : Promise.reject(new Error('Operation cancelled'))))
  10. }
  11. export default takePictureWithExpo