Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
if (status !== 'authorized') {
if (status === 'restricted') {
OkAlert('Cannot Access Calendar', 'Could not access calendar.');
return false;
} else if (status === 'denied') {
try {
// TODO(localization)
await OkCancelAlert(
'Cannot Access Calendar',
'Please open Settings to allow Calendar permissions.'
);
if (await Permissions.canOpenSettings()) {
Permissions.openSettings();
}
} catch (err) {
console.log('Canceled: Add to Calendar Permissions');
}
}
return false;
}
const { start, end } = getStartEndTime(event);
try {
CalendarEventsIOS.saveEvent(event.name, {
location: event.venue.fullAddress(),
notes: getDescription(event),
startDate: start.toISOString(),
endDate: end.toISOString(),
export async function requestReadContactPermission (callback) {
try {
Permissions.requestPermission('contacts').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
export async function requestCameraPermission (callback) {
try {
Permissions.requestPermission('camera').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
return false;
}
}
if (status !== 'authorized') {
if (status === 'restricted') {
OkAlert('Cannot Access Calendar', 'Could not access calendar.');
return false;
} else if (status === 'denied') {
try {
// TODO(localization)
await OkCancelAlert(
'Cannot Access Calendar',
'Please open Settings to allow Calendar permissions.'
);
if (await Permissions.canOpenSettings()) {
Permissions.openSettings();
}
} catch (err) {
console.log('Canceled: Add to Calendar Permissions');
}
}
return false;
}
const { start, end } = getStartEndTime(event);
try {
CalendarEventsIOS.saveEvent(event.name, {
location: event.venue.fullAddress(),
notes: getDescription(event),
startDate: start.toISOString(),
export async function checkReadContactPermission (callback) {
try {
Permissions.getPermissionStatus('contacts').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
export async function checkCameraPermission (callback) {
try {
Permissions.getPermissionStatus('camera').then(response => {
let granted = false
if (response === 'authorized') {
granted = true
}
// response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
return callback(null, granted)
})
} catch (err) {
console.error(err)
callback(err, null)
}
}
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');
}
window.setTimeout(async () => {
const { navigate } = this.props.navigation;
try {
const permissions = await Permissions.checkMultiple(['microphone', 'location']);
if (Platform.OS === 'ios' // Android doesn't need to handle permission explicitly
&& (permissions.microphone !== 'authorized'
|| permissions.location !== 'authorized')) {
this.props.navigation.navigate('PermissionSettings');
return;
}
const isAuthorized = await isAuthorizedAsync();
if (!isAuthorized) {
navigate('Auth');
return;
}
// Permission has been granted (for iOS only) and readerSDK has been authorized
this.props.navigation.navigate('Checkout');
return new Promise(async (resolve, reject) => {
Permissions.checkMultiple(['camera', 'photo', 'microphone']).then(response => {
// Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
const isCameraAuthorized = response.camera === 'authorized';
const isMicrophoneAuthorized = response.microphone === 'authorized';
const isStorageAuthorized = response.photo === 'authorized';
if (isCameraAuthorized && isMicrophoneAuthorized && isStorageAuthorized) {
resolve();
} else {
Alert.alert(
'Additional Permissions Required',
recordingPermissionsErrorMessage(isCameraAuthorized, isMicrophoneAuthorized, isStorageAuthorized),
[{text: 'OK'}],
{ cancelable: false }
);
// TODO: should put it in the catch so can pass in state
Analytics.logEvent('record_video_permissions_warning', {});
reject();