Add Calendar event to Android from web .vcs download

Santiago Rebella picture Santiago Rebella · Aug 6, 2012 · Viewed 15.5k times · Source

my current problem is the following; I am creating a website with two files for download(.vcs and .ics) that will add an event to the device calendar once clicked on the respective link. For the .ics in the iPhone I have no problem. My issue is that when downloading the .vcs file in Android it just opens a blank page showing the .vcs file content but is not downloading it neither recognizing the file as a calendar event.

I think as per what I read before in SO (and I was searching for that thread but could not find it now to reference) that has something to do with the mime type but after trying to figure out how to do it I cant make it work.

In that thread also they point to a site where the vcs file works for Android so is possible to do (I read many posts saying is not possible unless you download a calendar app from google play); http://plone.org/events/community/plone-conference-2011

I inspected that page source code and I am wondering if is something they are doing in the server side If you could please help me pointing out a direction to follow or a working solution or any advice you may have about it I will be thankfully.

PD - Is my first question in SO!

Answer

Santiago Rebella picture Santiago Rebella · Aug 6, 2012

Finally got it working adding a link to a location with this index.php

<?php
header("Content-Type: text/x-vCalendar");
header("Content-Disposition: attachment; filename=london2012.vcs");
?>
BEGIN:VCALENDAR
PRODID:-//AT Content Types//AT Event//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTAMP:20120801T133822Z
CREATED:20120801T042948Z
LAST-MODIFIED:20120801T043003Z
SUMMARY:Olympic Games
DTSTART:20120727T000000Z
DTEND:20120812T000000Z
LOCATION:London
URL:http://www.london2012.com/
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

Then from Android it downloads the file and you can import it to the calendar. Hope is usefull for someone else...