UIDocumentInteractionController unable to add ics

2019-03-16 01:45发布

问题:

I am trying to open an ics (Calendar) file within my iOS application.

For debug purposes i have added a ics file to my bundle of a calendar event created within iCal.

I am using UIDocumentInteractionController to present the data of the calendar invite with the hope of letting the user add it to their calendar.

However on presenting the UIDocumentInteractionController with in ics as the source file, it correctly shows all the data related to the event, however the button 'add to calendar' is replaced with 'This invitation data is out of date'

If i use the share option to send the file via SMS or Email and then try to open it, it works as expected using the UIDocumentInteractionController, therefore i don't think its an corrupt file.

I was wondering if i am missing something simple with the UIDocumentInteractionController or if this a known issue.

Any ideas would be great

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

self.documentController.delegate = self;
[self.documentController presentPreviewAnimated:YES];

Edit: I cannot use EKEvents as i need to add invitees to the event

回答1:

This may be irrelevant to your issue and probably explains nothing, but an employee was having an issue with his iPhone inconsistently accepting ICS calendar invites and was receiving "this invitation data is out of date" messages when it would not work. After multiple attempts of trial and error, the result was that if the iPhone was connected to wifi, it would give the "this invitation data is out of date" message. If it was connected only to the phone carrier network, it would successfully add the event.