ICS file Download fails on iPhone Chrome with “Unk

2019-06-22 09:18发布

问题:

I've got a php script that's auto-generating an ics file for a mobile web app.

Using Chrome on my Win7 desktop, the ics file downloads fine, and Outlook likes it.

Using Safari on my iPhone, the ics file opens the calendar app as expected, and allows me to add to calendar.

Using Chrome on my iPhone, I get "Download Failed. Chrome cannot download this file. Error 102 (): Unkown File Type."

I'm sending these headers:

header("Content-Type: text/Calendar; charset=utf-8");
header("Content-Disposition: inline; filename={$slug}.ics");
header("HTTP/1.0 200 OK", true, 200);

and my ics file output is:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//example.com//NONSGML blah blah//EN
METHOD:PUBLISH
BEGIN:VEVENT
UID:20130412T062148-527420343@example.com
DTSTAMP:20130412T062148
DTSTART:20130524T134500Z
DTEND:20130524T153000Z
LOCATION:
SUMMARY:This is the summary
DESCRIPTION:This is the description
STATUS:CONFIRMED
TRANS:OPAQUE
END:VEVENT
END:VCALENDAR

Any ideas about what iPhone Chrome isn't liking?

回答1:

It looks like a bug in Chrome for iOS. See https://bugs.chromium.org/p/chromium/issues/detail?id=666211



回答2:

most examples I see are in lowercase http://www.w3.org/Protocols/rfc1341/4_Content-Type.html

try making that

Content-Type: text/calendar

not

Content-Type: text/Calendar