Selecting an application from the UIDocumentInteractionController causes "LaunchServices: invalidationHandler Launch Error"

For some very strange reason, when I try to select the application displayed in the UIDocumentInteractionController, nothing happens. The console logs the error LaunchServices: invalidationHandler called, and I examined it to try to find a fix, but I do not come up with anything.

Below is my code for sending photos in the Instagram application. The menu appears very well and displays Instagram as the only parameter I want, but when I click on it, nothing happens except for the console message mentioned earlier.

- (void)addToInstagram
{
    // Save image to temporary file
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"add_to_insta.igo"];
    NSData *imageData = UIImagePNGRepresentation(self.energy.image);
    [imageData writeToFile:savedImagePath atomically:NO];
    NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/add_to_insta.igo"];
    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];

    // Pass into Instagram app
    CGRect rect = CGRectMake(0, 0, 612, 612);
    self.docFile = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
    self.docFile.UTI = @"com.instagram.exclusivegram";
    self.docFile.annotation = @{@"InstagramCaption": @"#capturedby_____"};

    [self.docFile presentOpenInMenuFromRect:rect inView:self.view animated:YES];
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"instagram://media?id=MEDIA_ID"]]){
        [self.docFile presentOpenInMenuFromRect:rect inView:self.view animated:YES];
    }else{
        UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:@"Instagram" message:@"You do not have Instagram installed." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
        [errorView show];
    }
}

Has anyone else accidentally encountered this error?

+4
2

UIDocumentInteractionController? , .

0

:

      dispatch_async(dispatch_get_main_queue(), ^() {

        [self.docFile presentOpenInMenuFromRect:rect inView:self.view animated:YES];

      });
0

All Articles