Reputation: 124
I wrote a simple php script to dynamically write an .ics file. The script is called when a HTML form is submitted:
<form id="m1-remind-form" action="/php/make_ics.php" method="get">
On the desktop it works fine. The file is downloaded, and when the user opens it the calendar event is added. On an iOS device with mobile Safari nothing happens. Even if I just directly link to a valid ics file, nothing happens. The mime-type, text/calendar, has been added to the server. The php gives these headers:
header("Cache-Control: private");
header("Content-Type: text/calendar; charset=utf-8");
header("Content-Disposition: attachment; filename=".$filename .".ics");
I've messed around with other mime-types and various header settings. Nothing seems to work.
I found a site where their dynamically created ics file downloads with mobile Safari and opens Calendar just fine and has the user experience I am looking for. See here: http://m.anderson.ucla.edu/today
They are using a .NET script to make the ics file, but that shouldn't make a difference.
Seems like it could be a server(IIS) issue, but we don't know what it could be. Any suggestions? I am at a loss here.
Upvotes: 2
Views: 3037
Reputation: 17
use this:
header("Content-Disposition: inline; filename=".$filename .".ics");
Upvotes: 0
Reputation: 124
Form button was not submitting on mobile Safari. On the desktop it did submit. Had to force submit on mobile with javascript.
btn.addEventListener('touchend', function(){form.submit()});
Not sure why?
Upvotes: 0