Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(),
const {formatMessage} = this.context.intl;
const file = this.getCurrentFile();
const items = [];
let permissionRequest;
const hasPermissionToStorage = await Permissions.check('photo');
switch (hasPermissionToStorage) {
case PermissionTypes.UNDETERMINED:
permissionRequest = await Permissions.request('photo');
if (permissionRequest !== PermissionTypes.AUTHORIZED) {
return;
}
break;
case PermissionTypes.DENIED: {
const canOpenSettings = await Permissions.canOpenSettings();
let grantOption = null;
if (canOpenSettings) {
grantOption = {
text: formatMessage({id: 'mobile.permission_denied_retry', defaultMessage: 'Settings'}),
onPress: () => Permissions.openSettings(),
};
}
const applicationName = DeviceInfo.getApplicationName();
Alert.alert(
formatMessage({
id: 'mobile.photo_library_permission_denied_title',
defaultMessage: '{applicationName} would like to access your photo library',
}, {applicationName}),
formatMessage({
id: 'mobile.photo_library_permission_denied_description',
hasPhotoPermission = async (source, mediaType = '') => {
if (Platform.OS === 'ios') {
const {formatMessage} = this.context.intl;
let permissionRequest;
const targetSource = source || 'photo';
const hasPermissionToStorage = await Permissions.check(targetSource);
switch (hasPermissionToStorage) {
case PermissionTypes.UNDETERMINED:
permissionRequest = await Permissions.request(targetSource);
if (permissionRequest !== PermissionTypes.AUTHORIZED) {
return false;
}
break;
case PermissionTypes.DENIED: {
const canOpenSettings = await Permissions.canOpenSettings();
let grantOption = null;
if (canOpenSettings) {
grantOption = {
text: formatMessage({
id: 'mobile.permission_denied_retry',
defaultMessage: 'Settings',
}),
onPress: () => Permissions.openSettings(),
};
}
const {title, text} = this.getPermissionDeniedMessage(source, mediaType);
Alert.alert(
title,
text,
openSettings = () =>
Permissions.canOpenSettings().then(canIt => {
if (canIt) {
return Permissions.openSettings();
}
Alert.alert(
'Not supported',
'openSettings is currently not supported on this platform',
);
});
hasPhotoPermission = async (source, mediaType = '') => {
if (Platform.OS === 'ios') {
const {formatMessage} = this.context.intl;
let permissionRequest;
const targetSource = source || 'photo';
const hasPermissionToStorage = await Permissions.check(targetSource);
switch (hasPermissionToStorage) {
case PermissionTypes.UNDETERMINED:
permissionRequest = await Permissions.request(targetSource);
if (permissionRequest !== PermissionTypes.AUTHORIZED) {
return false;
}
break;
case PermissionTypes.DENIED: {
const canOpenSettings = await Permissions.canOpenSettings();
let grantOption = null;
if (canOpenSettings) {
grantOption = {
text: formatMessage({
id: 'mobile.permission_denied_retry',
defaultMessage: 'Settings',
}),
onPress: () => Permissions.openSettings(),
};
}
const {title, text} = this.getPermissionDeniedMessage(source, mediaType);
Alert.alert(
title,
text,
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',
}),
onPress: () => Permissions.openSettings(),
};
}
const {title, text} = this.getPermissionDeniedMessage();
Alert.alert(
title,
text,
async function canOpenSettings() {
const res = await Permissions.canOpenSettings();
return res;
}
hasPhotoPermission = async (source, mediaType = '') => {
if (Platform.OS === 'ios') {
const {formatMessage} = this.context.intl;
let permissionRequest;
const targetSource = source || 'photo';
const hasPermissionToStorage = await Permissions.check(targetSource);
switch (hasPermissionToStorage) {
case PermissionTypes.UNDETERMINED:
permissionRequest = await Permissions.request(targetSource);
if (permissionRequest !== PermissionTypes.AUTHORIZED) {
return false;
}
break;
case PermissionTypes.DENIED: {
const canOpenSettings = await Permissions.canOpenSettings();
let grantOption = null;
if (canOpenSettings) {
grantOption = {
text: formatMessage({
id: 'mobile.permission_denied_retry',
defaultMessage: 'Settings',
}),
onPress: () => Permissions.openSettings(),
};
}
const {title, text} = this.getPermissionDeniedMessage(source, mediaType);
Alert.alert(
title,
text,