Skip to content

Instantly share code, notes, and snippets.

@alexHlebnikov
Created October 11, 2017 10:08
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 alexHlebnikov/2d746d9b21dd1d964706ca3cc76f9a75 to your computer and use it in GitHub Desktop.
Save alexHlebnikov/2d746d9b21dd1d964706ca3cc76f9a75 to your computer and use it in GitHub Desktop.
componentDidMount() {
if(Platform.OS == 'android' && Platform.Version >= 23)
this.getInitialAndroid23Location();
}
getInitialAndroid23Location = async () => {
try {
console.log('Asking for location permission');
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Location',
'message': 'Access to your location ' +
'for some reason.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('Location granted');
this._getInitialLocation();
} else {
console.log("Location permission denied")
}
} catch (err) {
console.warn(err)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment