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:
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.
I found a solution.
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.
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:
302
;302
location would include extra HTTP headers;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.