I was lead to this answer and that tells us how to create an offline calendar (I think) but how do I subscribe to a URL on a server that is spitting out a calendar in ics format? Is this possible?
Asked
Active
Viewed 2,706 times
1 Answers
6
Why not use this: How to programmatically add calendar subscriptions on iOS?
Summarizing the accepted answer:
NSString *url = @"http://server/filename.ics";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
Edit: Used this in my own app and verified that it works...
Edit by MitchR: For those generating their own ics feeds on the server, the url must end in .ics to receive the subscription prompt. The MIME type of the response must also be text/calendar. My server is a .NET/MVC server so I added a custom route so I could have the .ics on the end of the controller action.
-
Yes I've tried this - although I'm generating my ics feed on a url that doesn't end in .ics. Is that the difference? – Mike S Jun 07 '12 at 00:41
-
@MitchR That's probably the problem - it's possible that iOS doesn't recognize it as a calendar subscription. What happens when you try to use the code? – gtmtg Jun 07 '12 at 01:46
-
It simply opens Safari on the iPhone and shows the ics source text. I can subscribe to it in Mac OS X's iCal app - so that proves it is a valid feed. I'll try jigging my .NET feed to end in .ics and report back. – Mike S Jun 07 '12 at 03:01
-
@MitchR That would probably be your best option... this is probably a stupid suggestion, but maybe you can just take your URL and add .ics to the end of it. Because it is in ICS format, it might work... – gtmtg Jun 07 '12 at 12:32
-
Hmm - turns out it wasn't the "ics" bit on the end it was looking for, but I had to set the MIME type to be text/calendar. Now it works as you described. Unfortunately it appears to simply allow the importing of these events into your calendar - and not subscribing. – Mike S Jun 08 '12 at 05:41
-
@MitchR It does appear to update and resync, at least for me. I don't know exactly when it updates the calendar subscription, but if I run my app, add the calendar subscription (using this code), quit the simulator, add a new event to the calendar or change the details of an existing one, and reopen the simulator and open my app, the information is updated. If it makes any difference, I'm using the iCal (ics) subscription url of a Google Calendar. – gtmtg Jun 08 '12 at 18:25
-
Hmm. When I do it, it makes you select (or create) a new calendar and copy the events. The very process seems to indicate it is importing only and not setting up a subscription. Are you using iOS5? – Mike S Jun 12 '12 at 07:45
-
@MitchR Yeah, I'm running iOS 5.1 in the iPhone Simulator. I just bought a membership to the developer program yesterday, so I'll test it on my device and see if it's any different. – gtmtg Jun 12 '12 at 10:57
-
K that'd be great as I'm testing on the device. – Mike S Jun 13 '12 at 02:10
-
@MitchR On my device, when I tap the button to execute this code, it prompts me with an alert asking "Subscribe to the calendar 'Test Calendar'?" and two buttons, labeled "Subscribe" and "Cancel." Tapping "Subscribe" brings up a new alert a few seconds later, saying "The calendar 'Test Calendar' has been added" and two buttons, labeled "View Events" and "Done." I'm testing on an iPod Touch 4th-generation running iOS 5.1.1... Is this what you get? – gtmtg Jun 13 '12 at 02:22
-
No, I get the standard "open-with" screen - no mention of subscriptions. If I "Open-With" the calendar app, it just gives me the option to import to an existing calendar or create a new one. The ics feed I'm connecting to is my own one I'm generating with the DDay .NET plugin. Maybe there is some difference with the google ones? – Mike S Jun 13 '12 at 03:13
-
Edited your answer to include my findings. Interesting result. Thanks for your help @gtm. – Mike S Jun 15 '12 at 01:15
-
What about using `webcal` instead of `http`? I know that if you tap a link in Mobile Safari that starts with `webcal`, it uses the Calendar app to open and subscribe to the linked file, even if it doesn't end in .ics. – Tom Hamming Sep 18 '12 at 19:29
-
@Mr.Jefferson I've tried changing the URL handler to `webcal://` and it doesn't appear to work. It simply does nothing. – gtmtg Oct 14 '12 at 22:08