// @flow import Alert from 'utils/AlertUtils'; import { ImagePicker as ExpoImagePicker, Permissions } from 'expo'; export default { async launchCameraAsync(options: { allowsEditing?: boolean, quality?: number }): Promise<{ uri?: string }> { const { status: cameraPermission } = await Permissions.askAsync( Permissions.CAMERA ); const { status: cameraRollPermission } = await Permissions.askAsync( Permissions.CAMERA_ROLL ); if (cameraPermission === 'granted' && cameraRollPermission === 'granted') { return ExpoImagePicker.launchCameraAsync(options); } Alert.alert('Oops!', 'We need your permission to open the camera :('); return {}; }, async launchImageLibraryAsync(options: { mediaTypes?: 'Images' | 'Videos' | 'All', quality?: number }): Promise<{ uri?: string }> { const { status: cameraPermission } = await Permissions.askAsync( Permissions.CAMERA ); const { status: cameraRollPermission } = await Permissions.askAsync( Permissions.CAMERA_ROLL ); if (cameraPermission === 'granted' && cameraRollPermission === 'granted') { console.log('granted'); return ExpoImagePicker.launchImageLibraryAsync(options); } Alert.alert( 'Oops!', 'We need your permission to open your image library :(' ); return {}; } };