Reputation: 618
I have a website that generates dynamic calendar (icalendar). Lets assume that this calendar is accessible over HTTP at a URL like this
http://www.example.com/cal?q=<user query>
Everything works fine so far.
Now I want to let the users subscribe to this calendar with their favourite calendar client.
For ios I can achieve this if I publish the calendar URL with the webcal://
URL scheme.
Thank you
Upvotes: 20
Views: 2921
Reputation: 1645
If you specifically want to support importing to Google Calendar, you can construct a link to the google calendar website with the webcal url as a uri encoded query param. Here's what constructing that link looks like in JS:
"https://calendar.google.com/calendar/r?cid=" + encodeURIComponent("webcal://www.example.com/cal/whatever-the-link-is")
The downside to this is that there's (as of this writing) no mobile friendly version of the Google Calendar website that supports this feature, so the user will get this very non mobile friendly looking page:
And of course, this will method will not work for users who don't use Google Calendar. For them, it might be best to just provide them with a webcal link for them to import manually.
Upvotes: 4
Reputation: 4163
Since this is showing as unanswered, with upvotes on the question, I'm making my comment a more formal answer:
The 'standard' for calendar files is a http/s url .ics with mime type text/calendar. Webcal is just apple doing their own thing. All calendar applications should accept the open standard
Yes, if your url is publicly accessible, they can subscribe to it. Alternatively they can do a once off import
The RFC 5545 standard is the way to go for calendars and events https://www.rfc-editor.org/rfc/rfc5545#section-8.1
Upvotes: 3