selectImage.js 638 B

1234567891011121314151617181920212223
  1. import * as Permissions from 'expo-permissions'
  2. import * as ImagePicker from 'expo-image-picker'
  3. function selectImageWithExpo (options) {
  4. return new Promise((resolve, reject) => {
  5. return Permissions.askAsync(Permissions.CAMERA_ROLL)
  6. .then((isAllowed) => {
  7. if (!isAllowed) {
  8. return reject(new Error('Permissions denied'))
  9. }
  10. return ImagePicker.launchImageLibraryAsync(options)
  11. .then((result) => {
  12. console.log(result)
  13. if (!result.cancelled) {
  14. return resolve(result)
  15. }
  16. })
  17. })
  18. })
  19. }
  20. export default selectImageWithExpo