Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
let result = await request(permission)
switch (result) {
case RESULTS.UNAVAILABLE:
console.log('Bluetooth is not available (on this device / in this context)')
break
case RESULTS.DENIED:
console.log('The Bluetooth permission has not been requested / is denied but requestable')
break
case RESULTS.LIMITED:
console.log('The Bluetooth permission is limited: some actions are possible')
break
case RESULTS.GRANTED:
console.log('The Bluetooth permission is granted')
return true
case RESULTS.BLOCKED:
console.log('The Bluetooth permission is denied and not requestable anymore')
break
}
} catch (error) {
console.log('The Bluetooth permission request failed: ', error)
}
return false
}
const onConsentPress = async () => {
const result = await requestLocationPermission(apolloClient)
if (result === RESULTS.BLOCKED) {
Alert.alert(
'Location permission',
'Location permission is blocked in the device ' +
'settings. Allow the app to access location to ' +
'see location-based weather.',
[
{
text: 'OK',
onPress: () => {
Linking.openSettings()
},
},
],
)
return
}
switch (await check(cameraPermission)) {
case RESULTS.UNAVAILABLE:
this.setState({
error:
'This feature is not available (on this device / in this context)',
})
break
case RESULTS.DENIED:
this.requestPermission()
break
case RESULTS.GRANTED:
this.setState({
showCamera: true,
})
break
case RESULTS.BLOCKED:
this.setState({
error: 'The permission is denied and not requestable anymore',
})
break
}
}