iCal (.ics) subscription service with iPad and iPhone

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.

Downloading a static ics file from an iPad2

Downloading a static ics file via http from an iPad 2

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.

Subscribing to an ics file via webcal from an iPad 2

Subscribing to an ics file via webcal from an iPad 2

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”:

Default MIME type for an ics file in IIS7

Default MIME type for an ics file in IIS7

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.

Byte Order Mark

Byte Order Mark (BOM) being displayed using a hex-editor

Subscribing to an ics file via webcal from an iPad 2

Subscribing to an ics file via webcal from an iPad 2

Advertisements
  1. #1 by John Register on June 5, 2012 - 3:52 pm

    I’ve been wrestling with this problem for WEEKS, who knew it would be such a simple fix. Thank you so much for figuring out the solution for me. You are a gentleman and a scholar. =D

  2. #2 by Anjul on July 11, 2012 - 12:02 pm

    Thanks a lot! This was helpful.

    Although – do you notice that the “Auto Sync” does not work for the “Subscribed Calendars” in iPhone/ iPad – whereas it works fine on iCal, Outlook and Thunderbird. Any suggestions to make “Auto Sync” work on iPhone/ iPad?

  3. #3 by StupidMIMETypes on November 22, 2012 - 2:21 am

    You just prevented a suicide. THANKS!

  1. Synching iPhone with internet calendar (.ics) - Popular iPhone Questions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: