Sharing video to instagram with UIDocumentInteractionController
Asked Answered
P

0

9

How do you share an .mp4 video file to Instagram? I can share images like this:

NSString* filename = [NSString stringWithFormat:@"testImage.igo"];
        NSString* savePath = [imagesPath stringByAppendingPathComponent:filename];
        [UIImagePNGRepresentation(myImage) writeToFile:savePath atomically:YES];

        NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];

        if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
        {
            self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
            self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
            self.documentInteractionController.delegate = self;
            [self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
        }

But this only works for images. I tried renaming the video to testVideo.igo but that just results in a blank video. If Instagram requires files to have .igo extension how do you post a video file?

Proceleusmatic answered 24/3, 2014 at 23:26 Comment(2)
I have given an answer to this problem over here: #20017766Cazzie
The downside for @NicoHämäläinen's answer is that you must save the video to camera roll (in ios8 you can delete it after). Otherwise great answer.Exostosis

© 2022 - 2024 — McMap. All rights reserved.