12

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!

Auberon Vacher
  • 4,655
  • 1
  • 24
  • 36
Santiago Rebella
  • 2,399
  • 2
  • 22
  • 29
  • this is the SO post i finally found it: http://stackoverflow.com/questions/7700530/how-to-add-an-entry-in-the-android-calendar-from-an-html5-mobile-web-page . I tried adding http header header("Content-type: text/x-vCalendar; charset=utf-8"); header("Content-Disposition: attachment; filename='london2012.vcs'"); ?> but still does not works – Santiago Rebella Aug 06 '12 at 10:42
  • did you solve this problem? could you please help me out with the same. – vinay kumar Mar 16 '13 at 14:49
  • I solved it yes, the solution I used is in the answer, I dont know how you handle downloads in your app but is basically a link to a php file(an example in the answer). – Santiago Rebella Mar 18 '13 at 14:12
  • Do we need to handle it separately for importing the csv file? – vinay kumar Mar 18 '13 at 14:18
  • sorry but I dont understand what you mean, is just a link, where when you click goes to a php file that has the vcs specifying the header as in the solution. – Santiago Rebella Mar 18 '13 at 14:24
  • I have a link with vcs file, when ever i click on that it get downloaded, and I need to import that vcs file in to my android calendar application programatically is that possible? – vinay kumar Mar 18 '13 at 14:27

1 Answers1

21

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...

Santiago Rebella
  • 2,399
  • 2
  • 22
  • 29
  • Hi, I want the same implementation in one of my application, do we need to handled the downloaded file in our application through program? – vinay kumar Mar 16 '13 at 14:47
  • I copied above code and created one php file but after accessing vcs file get downloaded but it giving me same error "Can't Open file". – Kammy Nov 12 '14 at 09:34
  • @Kammy try to copy only the first 4 lines, then put your real event calendar, i mean, this calendar is from 2 years ago, maybe has something to do with your error – Santiago Rebella Nov 13 '14 at 18:17
  • @SantiagoRebella I tried it that too on my Kitkat 4.4.4 but it giving me same error. It it that android phone need other app to read ics/ical/vcs files as there is no default feature like iOS has? – Kammy Nov 16 '14 at 08:00
  • @Kammy with this approach i didnt need any app in android to be imported into native calendar – Santiago Rebella Nov 21 '14 at 14:05
  • 1
    Its working only for samsung smart phones. any solution for other providers (micromax,LG,Sony etc) – Dheeraj singh Jan 12 '15 at 12:46