Created
January 16, 2019 05:02
-
-
Save aloukissas/7b925d60ec381bb65defbe46530900ea to your computer and use it in GitHub Desktop.
This file contains 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 characters
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