On my website I have a button, and when I click on this button, I download a file called "event.ics". On Iphone, when the file is downloaded, he is automatically read and I can choose my calendar, but on Android and Windows Phone, I need to click on file downloaded or to go in folder "download" to execute the .ics
. Is there a way to read/execute the .ics
on Android and WP automatically ?
Here you can see my code to download the calendar file :
public function createEventCalendar($start, $end, $description, $location)
{
$event = array();
$rand = rand(5, 1000000000);
$event['name'] = "event";
$event['data'] = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TEST//TEST//EN
BEGIN:VEVENT
DTSTAMP:".date('Ymd\THis')."
STATUS:CONFIRMED
UID:".$rand."
DTSTART:".date('Ymd\THis', strtotime($start))."
DTEND:".date('Ymd\THis', strtotime($end))."
SUMMARY:Blablabla
DESCRIPTION:".$description."
LOCATION:".$location."
END:VEVENT
END:VCALENDAR";
return $event;
}
public function downloadEventCalendar($event)
{
$eventname = $event['name'].'.ics';
header("Content-Type: text/Calendar");
header("Content-Disposition: attachment; filename=\"".$eventname."\"");
echo $event['data'];
exit();
}
Thanks