Skip to content

Instantly share code, notes, and snippets.

@aloukissas
Created January 16, 2019 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aloukissas/7b925d60ec381bb65defbe46530900ea to your computer and use it in GitHub Desktop.
Save aloukissas/7b925d60ec381bb65defbe46530900ea to your computer and use it in GitHub Desktop.
import React from "react";
import { View, Text } from "react-native";
import { Permissions } from "expo";
class PermissionsExample extends React.Component {
state = {
message: ""
};
async componentWillMount() {
try {
const { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== "granted") {
this.setState({message: "Location permission was NOT granted!"});
} else {
this.setState({message: "Location permission was granted!"});
}
} catch (err) {
console.log(err);
}
}
render() {
return (
<View>
<Text>{this.state.message}</Text>
</View>
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment