takePicture.js 555 B

12345678910111213
  1. // Using leading underscore so eslint compat plugin doesn't yell at us.
  2. import * as _Permissions from 'expo-permissions'
  3. import * as ImagePicker from 'expo-image-picker'
  4. function takePictureWithExpo () {
  5. return _Permissions.askAsync(_Permissions.CAMERA)
  6. .then((isAllowed) => (isAllowed ? ImagePicker.launchCameraAsync({ allowsEditing: true })
  7. : Promise.reject(new Error('Permissions denied'))))
  8. .then((result) => (!result.cancelled ? result
  9. : Promise.reject(new Error('Operation cancelled'))))
  10. }
  11. export default takePictureWithExpo