UIDocumentInteractionController is shared via Instagram (and ONLY Instagram)

When I use the UIDocumentInteractionController to allow users to share via Instagram, it works, it opens the "open with" and "Instagram" options as one of the options ... the problem is that it also displays many other applications like Facebook "and" Twitter "...


Is there a way to do this, just give the opportunity to open in the instagram application?


Instagram claims there is a way to do this: http://instagram.com/developer/iphone-hooks/ , but they mention it:
"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 don't know what this part means, " extension class igo "

My code is:

 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]; 

Lcjmu.jpg

+5
source share
1 answer

It turns out that in order to access the doc controller only on Instagram, you just save the png or jpg file in an extension format like .igo. (Perhaps this only means Instagram)?

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

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

(With "igo")

in

and then it worked! :)

+10
source

Source: https://habr.com/ru/post/1206524/


All Articles