Merge pull request #1095 from punksta/patch-1

fix camera permission handle in android below 6.0
This commit is contained in:
Sibelius Seraphini 2018-01-12 11:53:29 -02:00 committed by GitHub
commit be0f94ceed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,10 +191,18 @@ export default class Camera extends Component {
message: this.props.permissionDialogMessage,
});
// On devices before SDK version 23, the permissions are automatically granted if they appear in the manifest,
// so check and request should always be true.
// https://github.com/facebook/react-native-website/blob/master/docs/permissionsandroid.md
const isAuthorized = Platform.Version >= 23
? granted === PermissionsAndroid.RESULTS.GRANTED
: granted === true;
this.setState({
isAuthorized: granted === PermissionsAndroid.RESULTS.GRANTED,
isAuthorizationChecked: true,
isAuthorized,
isAuthorizationChecked: true
});
} else {
this.setState({ isAuthorized: true, isAuthorizationChecked: true });
}