expo / firebase-storage-upload-example

This example has moved
https://github.com/expo/examples/tree/master/with-firebase-storage-upload
100 stars 29 forks source link

Unhandled promise rejection: Error: Missing camera roll permission #5

Open zeckdude opened 6 years ago

zeckdude commented 6 years ago

Is there some code missing in the example? When I start the expo app for this project, it shows the buttons but when you tap on either one, it shows the following message:

[00:17:57] [Unhandled promise rejection: Error: Missing camera roll permission.]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:123:42 in createErrorFromErrorData
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:80:57 in <unknown>
- ... 5 more stack frames from framework internals

Is there some code missing that should be asking the user for permission to access the camera/camera roll before taking/picking a photo?

zhgyuhui commented 6 years ago

https://github.com/expo/expo/issues/1707

`import {ImagePicker, Permissions} from 'expo';

askPermissionsAsync = async () => { await Permissions.askAsync(Permissions.CAMERA); await Permissions.askAsync(Permissions.CAMERA_ROLL);

};

//打开照相机 useCameraHandler = async () => {

    await this.askPermissionsAsync();
    let result = await ImagePicker.launchCameraAsync({
        // allowsEditing: true,
        aspect: [1, 1],
        base64: false,
    });

    if (!result.cancelled) {

    }

};

<Button onClick={ this.useCameraHandler }>拍照`