Kasper Basse
Kasper Basse

Reputation: 21

objective c - how can i open ics files on iphone

I have built an app for week numbers, and I have made an ics file with week numbers in, but how can I open it with Objective-C so it will subscribe into calender?

I can't figure out how I can do this. Are there any frameworks I can use, or what?

I have tried:

NSString *ical = [NSString stringWithContentsOfURL:
                 [NSURL URLWithString:@"http://xxxxxxxxxxx.xx/apps-iphone/weeknumber/ical/ical.ics"] encoding:NSUTF8StringEncoding error:NULL];

but I can open it with that.

It needs to look like this:

Hope you understand me. :)

Upvotes: 0

Views: 3258

Answers (1)

user1617119
user1617119

Reputation:

I'm pretending that you have the .ics file inside your app, right? And with this .ics file you want to open the Safari and have the alert?

Take a look at EventKit framework. You can integrate your app with the user's calendar. From EventKit's programming guide:

Event Kit not only allows your app to retrieve users’ existing calendar and reminder data, but it also lets your app create new events and reminders for any of their calendars. In addition, Event Kit lets users edit and delete their events and reminders (collectively known as “calendar items”). More advanced tasks, such as adding alarms or specifying recurring events, can be achieved with Event Kit as well. If a change to the Calendar database occurs from outside of your app, Event Kit is able to detect the change by notification so your app can act appropriately. Changes made to calendar items with Event Kit are automatically synced to the associated calendar (CalDAV, Exchange, and so on).


As an alternative, you can open it using this code:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://addressToYourics.ics"]];

But, unfortunately, you can't open bundle files with Safari, so I suggest you to use the EventKit library.


Take a look at another questions:
Is there a calendar control we can use for iPhone apps?
How to programmatically add calendar subscriptions on iOS?

Upvotes: 3

Related Questions