Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open .ics file in iOS App

Tags:

ios

icalendar

I need to open a .ics file in my app.

I tried to open it like this:

NSURL *path = [[NSBundle mainBundle] URLForResource:@"myIcsName" withExtension:@"ics"];
[[UIApplication sharedApplication] openURL:path];

But nothing is happening.

How do I open the .ics file?

like image 613
Abdullah Shafique Avatar asked Nov 25 '25 00:11

Abdullah Shafique


1 Answers

I just used the following code:

- (IBAction)displayICS:(id)sender
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"ics"];
    NSURL *url = [NSURL fileURLWithPath:path];
    UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:url];
    dc.delegate = self;
    [dc presentPreviewAnimated:YES];
}
-(UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self;
}
like image 127
Abdullah Shafique Avatar answered Nov 27 '25 23:11

Abdullah Shafique



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!