Created
July 29, 2018 17:56
-
-
Save jarvisluong/70fc7d7f36e54091b57d45974e2fc16b to your computer and use it in GitHub Desktop.
Revisions
-
jarvisluong created this gist
Jul 29, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ // @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 {}; } };