I'm creating an ICS file that works well with Android/Windows, but on iOS (Safari) it seems it has a problem working with downloading the file in proper format.
Using FileSaver.js extension.
Issue was highlighted back in 2013 - https://github.com/eligrey/FileSaver.js/issues/12
Similar issue on Stack - IOS Safari - How to download or display a pdf
<script>
const newEvent = {
BEGIN: 'VCALENDAR',
PRODID: 'ABC',
UID: 'info@info.com',
CATEGORIES: 'EVENT',
DTSTART: '20190321T153010Z',
DTEND: '',
SUMMARY: 'demo',
DESCRIPTION: 'demo',
END:'VEVENT',
END: 'VCALENDAR',
}
let formattedDate = formatDate(newEvent.DTSTART)
cal = ics()
cal.addEvent(newEvent.SUMMARY, newEvent.DESCRIPTION, newEvent.PRODID, formattedDate, formattedDate)
function formatDate(dateString) {
return dateString.replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/,"$1-$2-$3T$4:$5:$6")
}
download_calendar_btn.onclick = function() {
cal.download("Event")
}
</script>
What happens when clicking on the button is that instead of downloading the ICS file, on iOS it will redirect to an url as: blob:(my url) (followed by fileid)
and say it's an unknown document.