takePicture.js 526 B

1234567891011121314151617181920
  1. import Expo from 'expo'
  2. function takePictureWithExpo (options) {
  3. return new Promise((resolve, reject) => {
  4. return Expo.Permissions.askAsync(Expo.Permissions.CAMERA).then((isAllowed) => {
  5. if (!isAllowed) {
  6. return reject(new Error('Permissions denied'))
  7. }
  8. return Expo.ImagePicker.launchCameraAsync({ allowsEditing: true })
  9. .then((result) => {
  10. if (!result.cancelled) {
  11. return resolve(result)
  12. }
  13. })
  14. })
  15. })
  16. }
  17. export default takePictureWithExpo