9

Via the settings panel of your iPhone, you can add a subscription to a remote .ics calendar format. I have a Dutch iPhone app that does this from within the app (see the screenshot below, "abonneren op de agenda" means "subscribe to the calendar"), but there must be others too.

I want to mimic this behavior for a project of mine, but I can't find the API to do this with. It looks like it's not a part of EventKit, but because there's no app switching going on when you hit 'subscribe' in the example app I suspect it's also not a url scheme.

Who knows?

Existing app Subscriptions in the mail settings panel

epologee
  • 11,229
  • 11
  • 68
  • 104

1 Answers1

18

Try something like this:

NSString *url = @"http://server/filename.ics";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

This shows an uialertview with the question to the user if he/she wants to subscribe.

;)

Roeland Weve
  • 499
  • 3
  • 7
  • 1
    Great suggestion, stranger :P – epologee Oct 09 '11 at 18:47
  • 6
    I had trouble getting the alert to appear. Instead it showed a list of events that it wanted to add. I changed the scheme name from http:// to webcal:// and was able to subscribe. – nh32rg Oct 03 '13 at 19:02
  • What if my ics file is protected with http authentication method. Where to provide username and password? – Tushar Chhabhaiya Nov 15 '14 at 11:12
  • Can you use something like this? `NSString *url = @"http://username:password@server/filename.ics"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];` – Roeland Weve Dec 11 '14 at 14:51
  • Does this open Calendar directly ? Generally URL's are opened in Safari rite. How does iOS differentiate if this particular URL has to be sent to iCal ? Does it recognize .ics at the end ? – Yugandhar Pathi Dec 19 '17 at 19:24
  • I tested this in my App, it opens Safari first and then goes to Calendar. – Yugandhar Pathi Dec 19 '17 at 19:53