I am trying to create a calendar entry using ical on a mobile device using data: Uri, as described in https://stackoverflow.com/a/212832/16832 . Now it works fine on my desktop computer when I run it in Chrome and the application for my calendar is MS Outlook.
Basically what I do in Javascript:
var icalsample = "BEGIN:VCALENDAR\r\n\ VERSION:2.0\r\n\ PRODID:-\/\/mycompany.com\/myproduct\/\/NONSGML v1.0\/\/EN\r\n\ BEGIN:VEVENT\r\n\ UID:" + uuid + "@mycompany.com\r\n\ DTSTAMP:" + dtstamp.toISOString() + "\r\n\ ORGANIZER;CN=mycompany scheduler\r\n\ DTSTART:" + dtstart.toISOString() + "\r\n\ DTEND:" + dtend.toISOString() + "\r\n\ SUMMARY:" + title + "\r\n\ DESCRIPTION:" + description + "\r\n\ END:VEVENT\r\n\ END:VCALENDAR\r\n"; var uriContent = "data:text/calendar," + encodeURIComponent(icalsample); location.href = uriContent;
An example uriContent from my application is given below. When I copy and paste it into the Chrome address bar, it works as expected:
data:text/calendar,BEGIN%3AVCALENDAR%0AVERSION%3A2.0%0APRODID%3A-%2F%2Fmycompany.com%2Fmyproduct%2F%2FNONSGML%20v1.0%2F%2FEN%0ABEGIN%3AVEVENT%0AUID%3A3e40a5db-bfe3-4ab5-92c0-22cb7aeaa2d4%40mycompany.com%0ADTSTAMP%3A2013-03-15T18%3A17%3A55.792Z%0AORGANIZER%3BCN%3Dmycompany%20scheduler%0ADTSTART%3A2013-03-18T16%3A00%3A00.000Z%0ADTEND%3A2013-03-18T20%3A00%3A00.000Z%0ASUMMARY%3AService%20Appointment%0ADESCRIPTION%3Aupgrade.%0AEND%3AVEVENT%0AEND%3AVCALENDAR
My problem is that it does not work on iPhone or Android. From what I read, I thought the data: Uris was supported.
In Android 4.1.1, using the default browser (not Chrome), I see the text of my line being displayed as a text document in the browser. On the iPhone, I see "Download Error: Safari cannot load this file."
How can I make this work on iPhone and Android?
Update ---
There are some errors in the source code above. All lines must end with \ r \ n. I only had \ n. The last line also requires \ r \ n. The javascript Date.toISOString format is not valid for iCal. You must remove the dash, semicolon, and split second. A very useful tool for detecting these errors is the iical validator .
Most importantly, I donβt think Android supports iCal or ics files. There are many forum posts discussing this, and third-party tools to fill this gap. Therefore, I think that my code was right (except for the errors listed above in the update), but it failed on my phone because the application or Intent was not registered for the type mime / calendar mime.