Gilad
Gilad

Reputation: 618

URL Scheme to Trigger Calendar Client

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.

  1. Is there an equivalent URL scheme for Android ?
  2. Can I let the user import this calendar into his Google calendar ?
  3. Are there any other options that I didn't think about ?

Thank you

Upvotes: 20

Views: 2921

Answers (2)

Jemar Jones
Jemar Jones

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:

enter image description here

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

anmari
anmari

Reputation: 4163

Since this is showing as unanswered, with upvotes on the question, I'm making my comment a more formal answer:

  1. 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

  2. Yes, if your url is publicly accessible, they can subscribe to it. Alternatively they can do a once off import

  3. 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

Related Questions