Q: How can I have UIDocumentInteractionController show Calendar as an option for opening a .ics file? I am intercepting a type of URL in the webview I use in my app in order to download the file that it links to instead of just trying to open it in the webview. The link is to a .ics file. So I download that file into the temporary directory and then bring up the file in a UIDocumentInteractionController instance, but Calendar is not shown as one of the apps to open that .ics file in, just Mail, DropBox and "Copy".
As you can see in the commented out line in the code below I've tried making the link open with webcal:// at the front instead of http://, and also manually setting the UIDocumentInteractionController's UTI to no avail. Is there some reason my local .ics file would not show Calendar as an option for opening it?
//Test for link to an ics file
if ([urlToLoad rangeOfString:@"GetSingleEventCalendarFile" options:NSCaseInsensitiveSearch].location != NSNotFound)
{
    //urlToLoad = [urlToLoad stringByReplacingOccurrencesOfString:@"http" withString:@"webcal"];
    //NSData *contact = [NSData dataWithContentsOfURL:[NSURL URLWithString:webCalProtocol]];
    //return NO;
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlToLoad]];
    [NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *resp, NSData *respData, NSError *error){
        NSString *urlString = [req.URL absoluteString];
        NSString *actIdAndRest = [urlString substringFromIndex:[urlString rangeOfString:@"="].location + 1];
        NSString *actId = [actIdAndRest substringToIndex:[actIdAndRest rangeOfString:@"&"].location];
        NSString *fileName = [[@"activity" stringByAppendingString:actId] stringByAppendingString:@".ics"];
        NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
        NSError *errorC = nil;
        BOOL success = [respData writeToFile:path
                                     options:NSDataWritingFileProtectionComplete
                                       error:&errorC];

        if (success) {
            NSBundle * bundleContaining = [NSBundle bundleWithPath:NSTemporaryDirectory()];
            NSLog(@"%@", bundleContaining);
            NSURL *fileURL = [bundleContaining URLForResource:fileName withExtension:@"ics"];
            documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
            //documentController.UTI = @"ics";
            [documentController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
        } else {
            NSLog(@"fail: %@", errorC.description);
        }
    }];
}

