Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function requestLocationPermission() {
if (Platform.OS === 'ios') {
Geolocation.setRNConfiguration({
authorizationLevel: 'whenInUse'
})
Geolocation.requestAuthorization()
// IOS permission request does not offer a callback :/
return null
} else if (Platform.OS === 'android') {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
return true
} else {
return false
}
} catch (err) {
console.warn(err.message)
return false
}