Data: uri for ical does not work on Android or iPhone

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.

+4
source share
2 answers

I had the same problem - and until I found this stream, I could not get the iPhone to read my iCal file.

Safari would say, β€œSafari cannot load this file,” which is misleading - Safari uploaded the file, but did not like the standard ISO format date with dashes and colons.

The solution, as you correctly put it:

  • Make sure the line ending is CRLF.
  • Make sure there are no blank lines above BEGIN. VCALENDAR
  • Make sure the date format is ISO, but dashes and half columns are removed.

Thanks for pointing in the right direction!

+2
source

I tried this exact code and it works !!!

 BEGIN:VCALENDAR PRODID:-//Some organization//some application//EN VERSION:2.0 METHOD:REQUEST BEGIN:VEVENT UID: 20120925T072912Z-140@http ://localhost/www/ CREATED:20120925T072912Z DTSTAMP:20120922T090500Z DTSTART:20120922T090500Z DTEND:20120923T090500Z DESCRIPTION:Please attend this sample meeting SUMMARY:Invitation to attend training LOCATION:Earth ATTENDEE;RSVP=TRUE:mailto: periklis@example.com ORGANIZER; CN=periklis@example.com :mailto: periklis@example.com LAST-MODIFIED:20120922T090500Z PRIORITY:5 SEQUENCE:0 STATUS:CONFIRMED TRANSP:TRANSPARENT END:VEVENT END:VCALENDAR 
+1
source

All Articles