Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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(),
url: event.getUrl(),
});
} catch (e) {
console.warn(e);
}
return true;
}
async function saveEventToCalendar(event: EventType): Promise {
try {
await RNCalendarEvents.saveEvent(event.title, {
location: event.location,
startDate: event.startTime.toISOString(),
endDate: event.endTime.toISOString(),
description: event.description,
notes: event.description,
})
return true
} catch (err) {
Sentry.captureException(err)
console.error(err)
return false
}
}
}).then(id => {
RNCalendarEvents.saveEvent(title, {
id,
alarms: this.state.needNotice ? [{
date: before,
}] : []
}, {
futureEvents: true,
}).then((id) => {
idArray.push(id);
console.log(idArray.length);
console.log(courseData.filter(item => item.checked));
if (idArray.length === courseData.filter(item => item.checked).length) {
this.props.rootStore.LoadingStore.loading(false);
this.props.rootStore.UserStore.toast('success', `🎉 成功导入${idArray.length}节课程!可在系统日历中查看`);
this.props.rootStore.UserStore.clearToast();
}
});
= event.description
? `${event.description}\n\n${shareInfoText}`
: shareInfoText;
const updateObject = {
id: event.id,
...Platform.select({
ios: {
notes: updateText
},
android: {
description: updateText
}
})
};
RNCalendarEvents.saveEvent(event.title, updateObject)
.then(resolve, reject);
}, reject);
}, reject);