I recently ran into a problem the other day where a client of mine was having trouble with subscribing to a calendar that output an .ics file. They were able to subscribe to it via Outlook or the iCal application on a Mac, but were unable to subscribe with their Apple iPad 2 device. The error they kept receiving when attempting to subscribe was:
Cannot Subscribe Could not subscribe to the calendar xxx.ics from http://www.xxx.com
Quite descriptive, I know…
To solve this issue, there are a couple of things to keep in mind. The first thing to note is the difference between subscribing to a calendar, and simply downloading the static file. Going directly to a link for an .ics file (via http) will simply bring up the static file.
This is much different from a subscription in that any changes to the file would not show up in the calendar application. The alternative is to go to the file via the “webcal” protocol (eg: webcal://mydomain.com/test.ics). According to Wikipedia:
It is not an official URI scheme, such as http and ftp, as registered with IANA. The Webcal protocol prefix is used to trigger an external protocol handler which is passed the URL of the .ics file rather than being passed the downloaded contents of the file, in much the same way feed is sometimes used to trigger external RSS readers. The idea is that with this protocol prefix the target file should be subscribed to rather than imported into the calendar application as would happen with a simple download.
Accessing the same file via the webcal protocol will allow the iPad and iPhone to subscribe to the calendar rather than just download the file.
As you can see, the error that comes up is not very descriptive. For the case that my client had there were actually 2 problems. First of is the MIME type for this particular file extension. The hosting provider for my client was using IIS7 on a Windows Server 2008 box. By default, when you create a new site in IIS7, the MIME type for an .ics file is set to “application/octet-stream”:
Changing this to the standard “text/calendar” option will allow users to subscribe via the webcal protocol. Simple enough, but even after all of that both me and my client were unable to subscribe to the .ics file that he provided me. This ended up being an extremely difficult to track down bug but, in the end it was solved. What ended up happening is that this particular .ics file had a Byte Order Mark or (BOM) prepended to it (http://en.wikipedia.org/wiki/Byte_Order_Mark). Cracking the file open in a hex editor allowed me to remove this BOM and that allowed the file to be subscribed to via iPhone and iPad.