Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getPermission = () => {
Permissions.request('notification')
.then((response) => {
// if authorized, act
if (response === 'authorized') {
this.getNotificationToken()
}
})
}
public componentDidMount() {
// @ts-ignore
this.uploadPreview = this.refs.uploadPreview.refs.uploadPreviewModal;
Permissions.request('camera');
Permissions.request('photo');
}
const acquireMicPerm = async (): Promise => {
try {
const status = await check(
Platform.OS === 'ios' ? PERMISSIONS.IOS.MICROPHONE : PERMISSIONS.ANDROID.RECORD_AUDIO,
)
if (status === RESULTS.GRANTED) {
return MicPermStatus.GRANTED
}
try {
const status = await request(
Platform.OS === 'ios' ? PERMISSIONS.IOS.MICROPHONE : PERMISSIONS.ANDROID.RECORD_AUDIO,
)
if (status === RESULTS.GRANTED) {
return MicPermStatus.NEWLY_GRANTED
}
return MicPermStatus.DENIED
} catch (err) {
console.log(err)
}
} catch (err) {
console.log(err)
}
return MicPermStatus.UNDEFINED
requestCameraPermissionAndroid() {
return Permissions.request('camera').then((res) => {
if (res == 'authorized') {
this.resetCamera()
}
})
}
openCamera = async () => {
const statusPhoto = await Permissions.request('photo');
const statusCamera = await Permissions.request('camera');
this.setState({
permissionsGranted: statusPhoto === 'authorized' && statusCamera === 'authorized',
visibleModal: 'camera',
});
};
export const requestCameraPermission = () => Permissions.request('camera')
.then((permission) => permission === 'authorized')
Permissions.check('camera').then((response) => {
if (response === 'denied') {
if (Platform.OS === 'android') return
this.showPopupPermissionCamera()
} else if (response === 'undetermined') {
Permissions.request('camera', {
rationale: {
title: 'Camera Permission',
message: '"Golden" needs permission to access your device’s camera to scan QRCode'
}
}).then((res) => {
if (res === 'denied') {
if (Platform.OS === 'android') return
this.showPopupPermissionCamera()
}
})
}
})
}
const requestLocationPermission = async (
apolloClient: ApolloClient,
): Promise => {
promise = request(LOCATION_PERMISSION)
const result = await promise
apolloClient.writeData({
data: {
locationPermissionStatus: result,
},
})
refreshWeather(apolloClient)
return result
}
function getPermission(type) {
return Permissions.request(type)
}