I want let user input their Date, Time, SUMMARY... etc,
and create a .ics file, then put it into default calendar app to create event,
but it only working on Safari,
when I do this on Chrome, it will download .ics file.
Is possible make it work on both iOS and android?
Here is my code:
function convertDate(date, time) {
let dateStr = date.replaceAll('/', '');
let timeStr = time.replaceAll(':', '');
console.log(dateStr + 'T' + timeStr + '00');
return dateStr + 'T' + timeStr + '00';
}
function addEvent() {
let startDate = '2021/09/07';
let startTime = '14:30';
let endDate = '2021/09/07';
let endTime = '23:00'
var icsMSG =
"BEGIN:VCALENDAR\n" +
"METHOD:PUBLISH\n" +
"PRODID:-//VMFIVE//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"DTSTART:" + convertDate(startDate, startTime) + "\n" +
"DTEND:" + convertDate(endDate, endTime) + "\n" +
"SUMMARY:" + 'TEST EVENT' + "\n" +
"DESCRIPTION:" + 'TEST DESCRIPTION' + "\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
window.open("data:text/calendar;charset=utf8," + escape(icsMSG));
}