I have events (fetched using iCloud account) in my calendar, now I want to invite and share an event via contacts or mail. On invitation I need to attach this event details. The details will also be appeared on those calendars who are invited by me, when they click on invitation. Can anyone suggest the method to follow.
There are no methods of EKEvent which allows you to save it to file. The only way I see is to create file on your own, it should have VCalendar (.iCal extension) format. Just save event to file according to suggested below library. You can use mail composer or UIActivityViewController
to share event to invite people.
Library URL : https://github.com/mysterioustrousers/EKEventToiCal
To attach it along with the email in the MFMailComposer using this below code:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *WritableDBPath= [documentsDirectory stringByAppendingPathComponent:kFilename];
NSData *data = [NSData dataWithContentsOfFile:WritableDBPath];
[picker addAttachmentData:data mimeType:@"text/calendar" fileName:@"/abc.ical"]; [picker setSubject:@"Database"];
[picker setMessageBody:@"Database testing" isHTML:NO];
[self presentModalViewController:picker animated:YES];
Let me know if you have any queries.