Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentInteractionController share via Instagram (and ONLY Instagram)

When I use UIDocumentInteractionController to allow users to share via Instagram, it does work, it brings up the option for "open with" and "Instagram" as one of the options... the problem is that it also displays many other apps like "Facebook" and "Twitter"...


Is there any way I can make it only give the option of opening in the instagram app?


Instagram claims there is a way to do this: http://instagram.com/developer/iphone-hooks/ but they mention this:
"Alternatively, if you want to show only Instagram in the application list (instead of Instagram plus any other public/jpeg-conforming apps) you can specify the extension class igo, which is of type com.instagram.exclusivegram."

but I honestly have no clue what this part means, "extension class igo"

My code:

UIImage *imageToUse = [UIImage imageNamed:@"imageToShare.png"];
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
docController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
docController.delegate = self;
docController.annotation = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"This is the users caption that will be displayed in Instagram"], @"InstagramCaption", nil];
docController.UTI = @"com.instagram.exclusivegram";
[docController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:self.view animated:YES];

like image 708
Albert Renshaw Avatar asked Nov 09 '14 21:11

Albert Renshaw


2 Answers

Turns out to get the doc controller to only open in Instagram you just save your png or jpg file in format ".igo" file type extension, (Maybe stands for Instagram-Only?)



Changed the third line of code in my code to read this instead:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

(With "igo")



and then it worked! :)

like image 136
Albert Renshaw Avatar answered Oct 30 '22 00:10

Albert Renshaw


Lower version of iOS 13:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

After iOS 13:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];
like image 37
naresh kolindala Avatar answered Oct 30 '22 01:10

naresh kolindala