Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkPermission = async () => {
const p = await Permissions.check('microphone');
console.log('permission check', p);
if (p === 'authorized') return;
return this.requestPermission();
};
onPress: async () => {
setActiveTab(TabItems.Gallery)
if (Platform.OS === 'ios') {
try {
const status = await check(PERMISSIONS.IOS.PHOTO_LIBRARY)
if (status !== RESULTS.GRANTED) {
try {
const status = await request(PERMISSIONS.IOS.PHOTO_LIBRARY)
if (status !== RESULTS.GRANTED) {
setSecurityAccessVisibility(true)
return
}
} catch (err) {
console.log(err)
}
}
} catch (err) {
console.log(err)
}
}
},
checkPermission = async () => {
const p = await Permissions.check('microphone');
console.log('permission check', p);
if (p === 'authorized') return;
return this.requestPermission();
};
Promise.all(PERMISSIONS_VALUES.map(_ => RNPermissions.check(_)))
.then(statuses => this.setState({statuses}))
const resolveLocationPermissionStatus = () => {
if (promise) return promise
promise = check(LOCATION_PERMISSION)
return promise
}
async componentDidAppear() {
this.toggleScannerMode(true)
let status = await Permissions.check('camera')
if (status === 'undetermined') {
status = await Permissions.request('camera')
}
this.setState({ ...this.state, hasPermission: status === 'authorized' })
}
async checkPermission() {
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({
requestPhotoPermission(callback = () => { }) {
NavStore.preventOpenUnlockScreen = true
Permissions.check('photo').then((response) => {
if (response != 'authorized') {
Permissions.request('photo').then((res) => {
if (res == 'authorized') {
callback()
}
})
}
})
}
requestPermissions = async () => {
const {formatMessage} = this.context.intl;
let permissionRequest;
const hasMicPermissions = await Permissions.check('microphone');
switch (hasMicPermissions) {
case PermissionTypes.UNDETERMINED:
permissionRequest = await Permissions.request('microphone');
return {
hasPermission: permissionRequest === PermissionTypes.AUTHORIZED,
requested: true,
};
case PermissionTypes.DENIED: {
const canOpenSettings = await Permissions.canOpenSettings();
let grantOption = null;
if (canOpenSettings) {
grantOption = {
text: formatMessage({
id: 'mobile.permission_denied_retry',
defaultMessage: 'Settings',