Created
October 11, 2017 10:08
-
-
Save alexHlebnikov/2d746d9b21dd1d964706ca3cc76f9a75 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
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