iosicalendarcaldav

How to prevent iOS from suggesting to subscribe to an ICS file online?


I am running a newsletter about some events for which I want to include a "Add to calendar" link.

To do so, I am hosting some ICS files on Linode's Object Storage (which is S3-compatible). Here is an exemple of a URL for a calendar event: https://app-statium.eu-central-1.linodeobjects.com/25782331-363c-4ba6-b255-b10f87a30895.ics.

My problem is that when this link is being tapped on from an iOS or iPadOS device, Calendar will offer to subscribe to the URL rather than just adding the event from the file in the calendar. Here is a screenshot:

Screenshot of Calendar app on iPadOS that suggests to subscribe to the ICS URL.

On the other hand, on macOS, the behavior is as expected: Calendar opens and shows the event. No subscription to the URL is suggested.

Is there any ways I could get iOS to behave the same as macOS with these links? I investigated if some query params or HTTP header could say "no subscription please" but didn't find anything.


Solution

  • I found a solution.

    TL;DR

    The e-mail should not link to the ICS resource directly. Instead, it should respond with a temporary redirection HTTP status code (ie 302, 303 or 307) with the location of the final ICS resource.

    How I got there

    To find this solution, I reverse engineered a link that behaved the way I wanted (ie add the event, no subscription). I found the following differences between the working behaviour and the behaviour I had:

    1. The link from the e-mail responded with a 302;
    2. An HTTP get response to the 302 location would include extra HTTP headers;
    3. The final ICS resource would include extra metadata.

    After attempting to mimic these 3 different behaviours, only the 302 hack ended up working the way I wanted. 🤷

    I ended up responding with a better-suited 303 which behaves as intended.