Parsa Amini
Parsa Amini

Reputation: 33

Import .ics file to iOS user calendar

I'm trying to add .ics files to the users calendar. I've tried the UIDocumentInteractionController to do this, but this only shows a preview window and not the view to add the events, like it does when you e.g. open a .ics file with the iPhone Mail App. this is my code:

 NSString * filePath =
[[NSBundle mainBundle]
 pathForResource:@"myCal" ofType:@"ics"];

self.documentController =
[UIDocumentInteractionController
 interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

self.documentController.delegate = self;

[self.documentController presentPreviewAnimated:YES];

What am I doing wrong? Or is there even a way to just add the events of the .ics file to the calendar programmatically (instead of creating many EKEvents)?

Thanks

Upvotes: 3

Views: 3222

Answers (1)

Paresh Navadiya
Paresh Navadiya

Reputation: 38239

Use MXLCalendarManager. A set of classes to parse and handle iCalendar(.ICS) files. The framework can parse through an iCalendar file and extract all VEVENT objects into MXLCalendarEvent items. Then, by running the checkDate: or checkDay:month:year you can see if the event occurs on a certain day.

Upvotes: 1

Related Questions